Wassinger
Wassinger

Reputation: 387

nginx responds to HTTPS but not HTTP

I am using the dockerized Nextcloud as shown here: https://github.com/nextcloud/docker/tree/master/.examples/docker-compose/with-nginx-proxy-self-signed-ssl/mariadb/fpm

I set this up with port 80 mapped to 12345 and port 443 mapped to 12346. When I go to https://mycloud.example.com:12346, I get the self-signed certificate prompt, but otherwise everything is fine and I see the NextCloud web UI. But when I go to http://mycloud.example.com:12345 nginx (the proxy container) gives error "503 Service Temporarily Unavailable". The error also shows up in proxy's logs.

How can I diagnose the issue? Why is HTTPS working but not HTTP?

Upvotes: 0

Views: 1215

Answers (1)

Rémy
Rémy

Reputation: 454

Can you provide your docker command starting nextcloud, or docker-compose file ?

Diagnosis is as usual with docker stuff : get the id for the currently running container

docker ps

Then check the logs

docker logs [id or name of your container] docker-compose logs [name of your service]

Connect in the container

docker exec -ti [id or name of your container] [bash or ash if alpine based container]

There read the nginx conf files involved. In your case I'ld check the redirection being made from http to https, most likely it's something like below with no specific port specified for https, hence port 443, hence not working

server {
       listen         80;
       server_name    my.domain.com;
       return         301 https://$server_name$request_uri;    <======== no port = 443
}

server {
       listen         443 ssl;
       server_name    my.domain.com;
       # add Strict-Transport-Security to prevent man in the middle attacks
       add_header Strict-Transport-Security "max-age=31536000" always; 

       [....]
}

Upvotes: 1

Related Questions