Forum

Hiawatha as reverse proxy for Collabora Office docker image

Nick
3 May 2017, 13:59
Hi All,

Hoping this is possible with hiawatha.

I have a debian 8 VM currently serving nextcloud with hiawatha. The configuration for nextcloud came from this forum and its working great.

Binding {
Port = 443
TLScertFile = /etc/hiawatha/tls/my-website.pem
MaxRequestSize = 2048
TimeForRequest = 30
}



VirtualHost { # my-website.uk
Hostname = www.my-website.uk, my-website.uk
WebsiteRoot = /var/www/hiawatha/nextcloud
AccessLogfile = /var/log/hiawatha/my-website.uk/access.log
ErrorLogfile = /var/log/hiawatha/my-website.uk/error.log
RequireTLS = yes
TimeForCGI = 5
UseFastCGI = PHP7
UseToolkit = nextcloud
WebDAVapp = yes
EnablePathInfo = yes
StartFile = index.html
}



UrlToolkit {
ToolkitID = nextcloud
Match ^/\.well-known/host-meta(\?(.*))? Rewrite /public.php?service=host-meta&$2
Match ^/\.well-known/host-meta\.json(\?(.*))? Rewrite /public.php?service=host-meta-json&$2
Match ^/\.well-known/carddav Rewrite /remote.php/dav/
Match ^/\.well-known/caldav Rewrite /remote.php/dav/
Match ^/remote/([^?]*)(\?.*)? Rewrite /remote.php$2
# Match ^/(?:build|tests|config|lib|3rdparty|templates)/.* DenyAccess
Match ^/.well-known/acme-challenge/.* Return
# Match ^/(?:\.|autotest|occ|issue|indie|db_|console).* DenyAccess
}



Now however, I'd like to integrate Collabora Office into nextcloud. I've had a hunt through the forums but can't find the information I need. Mostly I'm struggling with the concept of a docker image and how hiawatha interacts with it.

On the Collabora Online website they give the following configuration for nginx reverse proxying.

server {
listen 443 ssl;
server_name collabora.example.com;

ssl_certificate /path/to/ssl_certificate;
ssl_certificate_key /path/to/ssl_certificate_key;

# static files
location ^~ /loleaflet {
proxy_pass https://localhost:9980;
proxy_set_header Host $http_host;
}

# WOPI discovery URL
location ^~ /hosting/discovery {
proxy_pass https://localhost:9980;
proxy_set_header Host $http_host;
}

# Main websocket
location ~ /lool/(.*)/ws$ {
proxy_pass https://localhost:9980;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_read_timeout 36000s;
}

# Admin Console websocket
location ^~ /lool/adminws {
proxy_pass https://localhost:9980;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_read_timeout 36000s;
}

# download, presentation and image upload
location ^~ /lool {
proxy_pass https://localhost:9980;
proxy_set_header Host $http_host;
}
}


Is it possible to convert the following into a hiawatha configuration? Does hiawatha support WOPI?

Thanks
Nick
3 May 2017, 16:59
So I think I have a good start for the configuration of a reverse proxy vhost.

VirtualHost { # office.my-website.uk
Hostname = office.fresh-website.uk
ReverseProxy .* http://127.0.0.1:9980/
WebsiteRoot = /var/www/hiawatha/office # Blank Directory
AccessLogfile = /var/log/hiawatha/office.my-website.uk/access.log
ErrorLogfile = /var/log/hiawatha/office.my-website.uk/error.log
RequireTLS = yes
}



One of the bits I didn't understand was that I needed to specify a WebRoot however, I found in the forums that I could simply point WebRoot at an empty directory.

That said, this still does not work. I know requesting office.my-website.uk attempts to connect as it sees the self signed cert in the docker image. Yet it does not load anything. I'm guessing I need to convert the nginx location directives to hiawatha. I'm afraid this is a bit beyond my current capabilities. Thanks for any help.
Hugo Leisink
3 May 2017, 20:49
I'm not familiar with the Nginx configuration syntax, but I see several URI's mentioned for the reverse proxy configuration. Is that the matching pattern for sending it to the reverse proxy? If so, what about this:
VirtualHost {
...
ReverseProxy ^/loleaflet http://127.0.0.1:9980/
ReverseProxy ^/hosting/discovery http://127.0.0.1:9980/
ReverseProxy ^/lool/(.*)/ws$ http://127.0.0.1:9980/
ReverseProxy ^/lool/adminws http://127.0.0.1:9980/
ReverseProxy ^/lool http://127.0.0.1:9980/
...
}

I have no idea what the proxy_set_header with Upgrade and Connection do. To me, it looks like another case of stuff that should actually be part of the application itself and not be present in the configuration of a webserver.
This topic has been closed.