Default-virtualhost.inc (SOGo httpd configuration)

Ive been looking in to sogo httpd configuration so fa so good have a basic template to work with.

Just that default-virtualhost.inc is a complete mystery to me, not strange having barely basic knowledge of this stuff. IMHO it is does nothing… where are the the variables such as hostname %{HTTP_HOST} and servername (%{SERVER_NAME} “declared”.

What is the supposed use of default-virtualhost.inc? Take SOGo DAV as an example, if http://domain/dav should point at https://domain/SGOo/dav. Is this something you do with a rewrite rule in there?

EDIT: read #5088 none of the test cases work :confounded:
Tagged it as bug.
EDIT 2: Got it, in the existing nethservers-sogo package there are some un-needed ESC- characters
Re-Tgged it as development

1 Like

You are talking of this, the purpose is to force the https redirection and to force the use of /SOGo

The default-virtualhost.inc has just been introduced with NS7, before it was in /etc/e-smith/templates/httpd/vhost-default/

Yes that exactly what i mean, for dav and (dav)iOS support we need some re directions to /SOGo/dav.
AFAIK, this can be done with a rewrite rules in default-virtualhost.inc, or proxypasses in the httpd SOGo.conf (This was the “old” used method).
I would prefer the first; right now it does not work for me;

Could you try:

TEST CASE

upgrade nethserver-httpd package

server-manager redirect: http://<IP>/server-manager/ redirects to https://<IP>:980/

Thanx for the help!

Oops this works!

Sogo redirect does not…

htttp://domain/sogo does not redirect to `https://domain/SOGo`

could it be (%{SERVER_NAME} ?

try this https://github.com/stephdl/nethserver-tt-rss/blob/ns7/root/etc/e-smith/templates/etc/httpd/conf.d/default-virtualhost.inc/50tt-rss

1 Like

at the end a proxypass has not the same goal as a redirection

a proxypass is used to redirect https://yourdomain/something to a specific port (https://yourdomain:980)

a redirection is to rewrite the url.

that’s why I (in principal) prefer the rewrite rule;
just don’t know that much of this stuff…

1 Like

2 questions remain:

  • In the rewrite rule, what is the difference between %{SERVER_NAME} and %{HTTP_HOST} , my hunch is the later is used for virtual domains; the first redirects to the default domain
  • Is it oke to put the “DAV” rewrite rules in default-virtualhost.inc, i think we need about 5 of those.

@giacomo think I almost got it, no need to deliver a working package…

1 Like

I couldn’t find official Apache documentation.
AFAIK:

  • SERVER_NAME : hostname from the virtual hosts
  • HTTP_HOST : hostname or IP address requested by the client

I’d use HTTP_HOST to have rewrite rules which work with IP and hostname.

Maybe you already found it, but there is documentation for rewrites and virtualhost.inc right here: https://github.com/nethserver/nethserver-httpd (also in the developer manual)

1 Like

still in need of some help, got this now:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/dav(/.*)?$   https://%{HTTP_HOST}/SOGo/dav$1 [R=301,L] 

http://domain/dav get redirected to httpS://domain/SOGo/dav and auto discovery works :grin:
but
httpS://domain/dav is not redirected to httpS://domain/SOGo/dav :rage:

(capitalized the S for better understanding)

clue’s?

Are you sure that http 301 redirect response is accepted by all clients out there?

Apache config is tricky: mod_rewrite and the core modules, like mod_proxy do not fit well together! However mod_rewrite has proxypass features too…

This is the tricky part… Port 443 has a VirtualHost section (defined by mod_ssl.conf) where mod_rewrite does not inherit the settings from the global Server scope :frowning:

I’d try without mod_rewrite, by giving a try to RedirectMatch. On Apache 2.4 we have also IF blocks!

I do not care about this one, it’s nice to have

httpS://domain/dav is not redirected to httpS://domain/SOGo/dav

This is not, easier to do this in a proxypass as the former solution:?

ProxyPass /card/SOGo http://127.0.0.1:20000/SOGo interpolate
ProxyPass /card/principals http://127.0.0.1:20000/SOGo/dav/ interpolate`

This is @stephdl sme solution

# iOS auto discovery
RedirectMatch ^/principals/users/(.*)$ /SOGo/dav/$1
RedirectMatch ^/principals/$ /SOGo/dav/
RedirectMatch ^/.well-known/(caldav|carddav)$ /SOGo/dav/
2 Likes

Wherever possible, it’s better to apply the setup from upstream :wink:

Sometimes it comes together with some limitations…

1 Like