Improve routing between containers

Create user network nginx-internal
and use Docker's internal DNS server
to resolve containers by hostname.
This commit is contained in:
Lukáš Kucharczyk 2021-04-27 23:09:21 +02:00
parent d9bd3ac145
commit 54de631d29
No known key found for this signature in database
GPG Key ID: 65524498C0196B64
4 changed files with 12 additions and 4 deletions

View File

@ -11,6 +11,8 @@
docker_container:
name: 'jellyfin'
image: linuxserver/jellyfin
networks:
- name: nginx-internal
volumes:
- "{{ data_folder }}/jellyfin:/config"
- "{{ media.tv }}:/data/tv"

View File

@ -1,15 +1,12 @@
server {
listen 80;
server_name "jellyfin.{{ base_domain }}";
set $jellyfin {{ server_ip }};
#resolver 127.0.0.1 valid=30;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name "jellyfin.{{ base_domain }}";
set $jellyfin {{ server_ip }};
set $jellyfin jellyfin;
# Security/XSS Mitigation Headers
add_header X-Frame-Options "SAMEORIGIN";

View File

@ -58,10 +58,18 @@
src: nginx.conf.j2
dest: "{{ data_folder }}/nginx/nginx.conf"
mode: '0755'
- name: create nginx bridge network
docker_network:
name: nginx-internal
attachable: true
internal: true
state: present
- name: run container
docker_container:
name: 'nginx'
image: nginx
networks:
- name: nginx-internal
volumes:
- "{{ data_folder }}/nginx/nginx.conf:/etc/nginx/nginx.conf"
- "{{ data_folder }}/nginx/{{ base_domain }}.key:/etc/nginx/{{ base_domain }}.key"

View File

@ -26,6 +26,7 @@ http {
keepalive_timeout 65;
#gzip on;
resolver 127.0.0.11 valid=30;
ssl_certificate /etc/nginx/{{ base_domain }}.crt;
ssl_certificate_key /etc/nginx/{{ base_domain }}.key;
include /etc/nginx/conf.d/*.conf;