juliushaertl / nextcloud-docker-dev

Nextcloud development environment using docker-compose
GNU Affero General Public License v3.0
126 stars 67 forks source link

Running nextcloud-docker-dev on a different Port #305

Closed brccabral closed 5 months ago

brccabral commented 5 months ago

Hi, I have another service running on port 443 and 80 and wanted to run nextcloud-docker-dev on a different port. I set PROXY_PORT_HTTP=8070 and PROXY_PORT_HTTPS=7443 on my .env file, the docker compose created the master-proxy with these new ports, but when I access https://nextcloud.local:7443 it seems that the proxy sends me back to https://nextcloud.local which opens my other service, not Nextcloud. If I stop the other service, and use default proxy ports 443/80 then https://nextcloud.local is accessible, but I need the other service on 443.
Am I missing something or is it not possible to run nextcloud-docker-dev on a different port? Thanks

brccabral commented 5 months ago

Ok, I got it.

On my local nginx I set it to listen 443 only on my WiFi IP

server {
  ...
  listen 192.168.0.12:443
  ...
}

Just listen 443 makes it listen to all local IPs, *:443. To check it, run

sudo lsof -i -P -n | grep LISTEN | grep :443

Then, for the proxy, set it to listen to the gateway from the network master_default that nextcloud-docker-dev has created. To find it:

docker inspect master_default | grep Gateway

This can be changed with DOCKER_SUBNET. My .env now looks like this

...
DOCKER_SUBNET=192.168.21.0/24
...
PROXY_PORT_HTTPS=192.168.21.1:443

Now, recreate proxy with docker compose

docker compose up -d proxy

If I list the listening ports again with sudo lsof -i -P -n | grep LISTEN | grep :443 I can see both IPs listening to port 443

docker-pr 1333014            root    4u  IPv4 5985024      0t0  TCP 192.168.21.1:443 (LISTEN)
nginx     1335944            root   13u  IPv4 5999398      0t0  TCP 192.168.0.12:443 (LISTEN)
nginx     1335945        www-data   13u  IPv4 5999398      0t0  TCP 192.168.0.12:443 (LISTEN)

And finally I configure my DNS server (PiHole) to respond nextcloud.local to 192.168.21.4 (the proxy, not the gateway).