question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple hosts defined, second one does not get https config in /etc/nginx/conf.d/default.conf

See original GitHub issue

I have defined a second domain name in the Docker VIRTUAL_HOST env variable and I am not getting https for it.

When I check the /etc/nginx/conf.d/default.conf file I see the config

	# paste.xxx.dev
upstream paste.xxx.dev {
        ## Can be connected with "docker_debian03_net" network
        # privatebin
        server 172.16.241.3:8080;
}
server {
	server_name paste.xxx.dev;
	listen 80 ;
	access_log /var/log/nginx/access.log vhost;
	location / {
		proxy_pass http://paste.xxx.dev;
}
}
	# paste.xxx.yyy.dev
upstream paste.xxxyyy.dev {
        ## Can be connected with "docker_debian03_net" network
        # privatebin
        server 172.16.241.3:8080;
}
server {
	server_name paste.xxx.yyy.dev;
	listen 80 ;
	access_log /var/log/nginx/access.log vhost;
	# Do not HTTPS redirect Let'sEncrypt ACME challenge
	location ^~ /.well-known/acme-challenge/ {
		auth_basic off;
		auth_request off;
		allow all;
		root /usr/share/nginx/html;
		try_files $uri =404;
		break;
	}
	location / {
		return 301 https://$host$request_uri;
	}
}
server {
	server_name paste.xxx.yyy.dev;
	listen 443 ssl http2 ;
	access_log /var/log/nginx/access.log vhost;
	ssl_session_timeout 5m;
	ssl_session_cache shared:SSL:50m;
	ssl_session_tickets off;
	ssl_certificate /etc/nginx/certs/xxx.dev.crt;
	ssl_certificate_key /etc/nginx/certs/xxx.dev.key;
	add_header Strict-Transport-Security "max-age=31536000" always;
	location / {
		proxy_pass http://paste.xxx.yyy.dev;
}
}

docker-compose.yml

version: "3.9"
services:
  privatebin:
    container_name: privatebin
    image: privatebin/fs
    volumes:
      - /data/docker/privatebin/data:/srv/data
    environment:
      - TZ=Australia/Sydney
      - PHP_TZ=Australia/Sydney
      - VIRTUAL_HOST=paste.xxx.yyy.dev,paste.xxx.dev
      - VIRTUAL_PORT=8080
    networks:
      - debian03_net
    #ports:
      #- 8080:8080
    restart: unless-stopped

  nginx-proxy:
    container_name: nginx-proxy
    image: jwilder/nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /data/docker/certs:/etc/nginx/certs
    networks:
      - debian03_net
    restart: unless-stopped

networks:
  debian03_net:
    ipam:
      driver: default
      config:
        - subnet: 172.16.241.0/24

This line is causing the issue:

- VIRTUAL_HOST=paste.xxx.yyy.dev,paste.xxx.dev

The paste.xxx.dev only gets a port 80 definition and no port 443 config.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
sameeraksccommented, Oct 28, 2022

@ilium007 @Pearseak Guys I fixed this issue after updating the docker-composer.yaml version to version: ‘2’. previously I used 3.9

0reactions
sameeraksccommented, Oct 28, 2022

yeah that’s correct

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Nginx stopped: [emerg] 1#1: host not found in upstream
I have many servers in the config file, even if one server was down, I need to have running nginx. Is there any...
Read more >
Installing an SSL certificate on Nginx - Hosting - Namecheap
To install the SSL certificate on Nginx, you need to show the server which files to use, either by a) creating a new...
Read more >
Understanding the Nginx Configuration File Structure and ...
Nginx is one of the most popular web servers in the world, ... contexts can be layered within one another, Nginx allows configurations...
Read more >
How to Configure NGINX | Linode
This guide shows you several different NGINX server configurations. NGINX Config: Directives, Blocks, and Contexts. All NGINX configuration ...
Read more >
NGINX Configuration Guide: How to Get Started - Plesk
conf or etc/nginx/sites-enabled/default. No matter the installation source, though, server configuration files feature one or more server blocks ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found