Premise
In the past days I setup a home server running Mastodon with Docker. I already have a Nextcloud instance running on a Raspberry so now I'm trying to make both available thru dedicated subdomains (I'm using free DDNS).
I set up the two subdomains (both obviously point to my home router) like theese:
- mastodon.example.com
- nextcloud.example.com
Then I set up port forwarding in my router to send TCP/UDP traffic on ports 80, 443 to the same ports of the Mastodon server, while TCP/UDP traffic on custom ports 3000, 3001 is mapped to ports 80, 443 of the Nexcloud server.
Until here no problem, if I type https://mastodon.example.com
in the browser I get to the Mastodon server and with https://nextcloud.example.com:3001
I get to the Nextcloud one.
The problem
Now I'm trying to edit the configuration of the nginx-proxy container in the mastodon server in order to redirect every request for nextcloud.example.com
to nextcloud.example.com:3001
to avoid having to specify the port.
I created a new file myadditions.conf
in the folder mapped to the /etc/nginx/conf.d
volume of the container, and after restarting the server I can confirm nginx has loaded it correctly with docker exec nginx-proxy nginx -T
.
My problem is that everything I tryed to put in the file to make the redirect seems to be ignored, the result I get when I type nextcloud.example.com
is always the same: error MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT
(I'm using Firefox). I suppose that error is because the server is not trying to redirect the call and so the certificate it provides does not match with the nextcloud subdomain. Is there something I'm missing?
Currently my myadditions.conf
file looks like this:
server {
server_name nextcloud.example.com;
return 301 $scheme://nextcloud.example.com:3001$request_uri;
}
but I have tried a lot of settings without any change in the result, so I'm starting to think that the problem is not what I write in the file. By the way, also if I delete my file the error is the same.