Docker Community Forums

Share and learn in the Docker community.

Connection refused : Nginx HTTPS reverse proxy in docker container

docker

(Ganeshk) #1

Hi,

I wanted to setup https reverse proxy with nginx on docker container either ubuntu/centos. On Browser side, I am getting connection refused error. And also, I cannot see anything under /var/log/nginx/access.log or /var/log/nginx/error.log.

I am able to setup http reverse proxy with nginx on docker container again. And, also https reverse proxy with nginx on normal ubuntu and centos virtual machines.

Can understand the reason why https reverse proxy with nginx on docker containers is failing to connect from browser.?

If any additional information needed, I can provide you. Thanks in advance.

For reference, Please check this sites-available/default file.

server {
  listen 80;
  server_name localhost;
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl;
  server_name localhost;

  ssl_certificate /etc/nginx/ssl/cert.pem;
  ssl_certificate_key /etc/nginx/ssl/cert.key;

  ssl on;
  ssl_session_cache  builtin:1000  shared:SSL:10m;
  ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
  ssl_prefer_server_ciphers on;

  location ~* /rabbitmq/(.*) {
    rewrite ^\/rabbitmq\/(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:15672;
    proxy_set_header Host   $host;
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_redirect http:// https://;
  }

  location ~* /api/(.*) {
    rewrite ^/api/(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host   $host;
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_redirect http:// https://;
  }
}

Thanks, Ganesh


(Jeff Anderson) #2

I don’t see anything obviously wrong with this nginx config file.

How are you running nginx?