Geoff
Geoff

Reputation: 6639

Docker nginx with ubuntu not working on a custom port

I have set the following in my ubuntu nginx configuration with docker and this is the nginx configuration

server {
listen 6090;
server_name mydomain.com;
location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
       proxy_set_header   Host $http_host;
       proxy_pass         http://127.0.0.1:6090;

 }

}

The above fails to work but works when i change the listening port to 80 that is by changing listen 6090 to listen 80 it works. Am accessing this by visiting the url mydomain.com:6090

But i would like to visit my url as mydomain.com:6090 what else do i need to make this work

In the above mydomain.com is not the actual url.

UPDATES this is my docker configuration for nginx

webserver:
 image: nginx
 container_name: webserver
 restart: unless-stopped
 tty: true
 ports:
 - "80:80"
 - "443:443"

Upvotes: 0

Views: 63

Answers (1)

LinPy
LinPy

Reputation: 18578

you need to listen and expose the same Ports to make it works:

nginx config:

listen 6090;

compose:

 ports:
   - "6090:6090"

you expose port 80 therefore listen 80 will work ...

Upvotes: 1

Related Questions