Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen 443 port in jwilder/nginx-proxy

I am using the https://github.com/jwilder/nginx-proxy for nginx-proxy setting

The port 80 redirect is working. That means i can get to my site via non SSL using test.example.com but with HTTPS i get a chrome error of "This webpage is not available ERR_CONNECTION_CLOSED"

Then I found that default.conf from nginx-proxy seems doesn't listen 443 port:

upstream docker-reverse-proxy.com {
                            ## Can be connected with "test" network
                    # test_nginx_1
                    server 172.19.0.3:443;
}
server {
    server_name docker-reverse-proxy.com;
    listen 80 ;
    access_log /var/log/nginx/access.log vhost;
    location / {
            proxy_pass https://docker-reverse-proxy.com;
    }
}

Below is my configuation:

1) docker run -d -p 80:80 -p 443:443 -v /private/etc/ssl/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro --name nginx-proxy --net=test jwilder/nginx-proxy:alpine

2)docker-compose.yml

version: '3'

services:
  php-fpm:
    build: .
    restart: always
    volumes:
      - web:/www
    networks:
      - backend

  nginx:
    image: nginx:alpine
    restart: always
    environment:
      - VIRTUAL_HOST=docker-reverse-proxy.com
      - VIRTUAL_PROTO=https
      - VIRTUAL_PORT=443
    ports:
      - 80
      - 443
    volumes:
      - web:/www:ro
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - /private/etc/ssl/certs:/etc/nginx/certs
    networks:
      - frontend
      - backend
    depends_on:
      - php-fpm

volumes:
  web:

networks:
  backend:
  frontend:
    external:
      name: test
like image 420
Gary Ng Avatar asked Mar 14 '18 10:03

Gary Ng


People also ask

What is nginx reverse proxy Docker?

Nginx and Docker reverse proxy configurationA reverse proxy handles client requests, and then forwards those requests to another server that runs in the backend. This backend origin server processes the request and provides a response back to Nginx, which then sends the response back to the client.

What Nginx used for?

NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability.

How does nginx reverse proxy work?

A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server. A reverse proxy provides an additional level of abstraction and control to ensure the smooth flow of network traffic between clients and servers.


Video Answer


1 Answers

Finally solved by adding CERT_NAME under nginx server environment:

nginx:
  image: nginx:alpine
  restart: always
  environment:
    - VIRTUAL_HOST=docker-reverse-proxy.com
    - VIRTUAL_PROTO=https
    - VIRTUAL_PORT=443
    - CERT_NAME=YOUR_CERT_NAME ## Add this
like image 132
Gary Ng Avatar answered Nov 10 '22 23:11

Gary Ng