Last active
February 21, 2021 14:21
-
-
Save thraizz/788b6de673abc23551c76784a8fd5099 to your computer and use it in GitHub Desktop.
NGINX Reverse Proxy + Docker: Host it yourself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
nginx: | |
image: nginx:latest | |
container_name: production_nginx | |
volumes: | |
- /etc/letsencrypt/:/etc/letsencrypt/ | |
- ./nginx.conf:/etc/nginx/nginx.conf | |
- ./nginx/:/etc/nginx/ | |
- ./nginx/cache/:/etc/nginx/cache | |
- ./nginx/includes/:/etc/nginx/includes | |
ports: | |
- 80:80 | |
- 443:443 | |
qmwiki_backend: | |
image: thraizz/qmwiki_backend_data:latest | |
container_name: production-qmwiki_backend_data | |
ports: | |
- 3001:3001 | |
qmwiki_frontend: | |
image: thraizz/qmwiki_frontend:latest | |
container_name: production-qmwiki_frontend | |
expose: | |
- "4999" | |
lakur_landing: | |
image: thraizz/lakur_landing:latest | |
container_name: production-lakur_landing | |
expose: | |
- "4997" | |
lakur_landing-backend: | |
image: thraizz/lakur_landing-backend:latest | |
container_name: production-lakur_landing-backend | |
volumes: | |
- /srv/deployment/lakurLandingBackend/logs/:/var/src/apps/logs | |
ports: | |
- 3000:3000 | |
expose: | |
- "3000" | |
lakur_blog: | |
image: wordpress:latest | |
restart: always | |
container_name: production-lakur_blog | |
ports: | |
- 8000:80 | |
expose: | |
- "4996" | |
environment: | |
#WORDPRESS_DB_HOST: production-lakur_blog-db:3306 | |
#WORDPRESS_DB_USER: | |
#WORDPRESS_DB_PASSWORD: | |
#WORDPRESS_DB_NAME: | |
volumes: | |
- /srv/deployment/lakurBlog/wordpress:/var/www/html | |
lakur_blog-db: | |
image: mysql:latest | |
container_name: production-lakur_blog-db | |
restart: always | |
expose: | |
- "3306" | |
environment: | |
#MYSQL_DATABASE: | |
#MYSQL_USER: | |
#MYSQL_PASSWORD: | |
#MYSQL_RANDOM_ROOT_PASSWORD: | |
volumes: | |
- /srv/deployment/lakurBlog/mysql:/var/lib/mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events { | |
} | |
http { | |
error_log /etc/nginx/error_log.log debug; | |
client_max_body_size 20m; | |
proxy_cache_path /etc/nginx/cache keys_zone=one:500m max_size=1000m; | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
server_name _; | |
return 301 https://$host$request_uri; | |
} | |
# _ | |
# __ _____ _ __ __| |_ __ _ __ ___ ___ ___ | |
# \ \ /\ / / _ \| '__/ _` | '_ \| '__/ _ \/ __/ __| | |
# \ V V / (_) | | | (_| | |_) | | | __/\__ \__ \ | |
# \_/\_/ \___/|_| \__,_| .__/|_| \___||___/___/ | |
# |_| | |
server { | |
server_name blog.lakur.tech; | |
index index.php; | |
try_files $uri $uri/ =404; | |
listen 443 ssl; | |
ssl_certificate /etc/letsencrypt/live/lakur.tech/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/lakur.tech/privkey.pem; | |
include /etc/letsencrypt/options-ssl-nginx.conf; | |
# Use docker DNS for proxy resolving | |
resolver 127.0.0.11; | |
include /etc/nginx/includes/proxy.conf; | |
set $wordpress http://production-lakur_blog; | |
location / { | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_pass $wordpress; | |
} | |
} | |
# _ _ _ | |
# __ _ _ __ _____ _(_) | _(_) | |
# / _` | '_ ` _ \ \ /\ / / | |/ / | | |
# | (_| | | | | | \ V V /| | <| | | |
# \__, |_| |_| |_|\_/\_/ |_|_|\_\_| | |
# |_| | |
server { | |
listen 443; | |
server_name www.qmwiki.lakur.tech; | |
rewrite ^/(.*) https://qmwiki.lakur.tech/$1 permanent; | |
} | |
server { | |
server_name qmwiki.lakur.tech; | |
index index.html; | |
try_files $uri $uri/ =404; | |
listen 443 ssl; | |
ssl_certificate /etc/letsencrypt/live/lakur.tech/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/lakur.tech/privkey.pem; | |
include /etc/letsencrypt/options-ssl-nginx.conf; | |
# Use docker DNS for proxy resolving | |
resolver 127.0.0.11; | |
include /etc/nginx/includes/proxy.conf; | |
set $qmwiki http://production-qmwiki_frontend; | |
location / { | |
proxy_pass $qmwiki; | |
} | |
} | |
# _ _ _ _ _ | |
# | | __ _| | ___ _ _ __ | | __ _ _ __ __| (_)_ __ __ _ | |
# | |/ _` | |/ / | | | '__| | |/ _` | '_ \ / _` | | '_ \ / _` | | |
# | | (_| | <| |_| | | | | (_| | | | | (_| | | | | | (_| | | |
# |_|\__,_|_|\_\\__,_|_| |_|\__,_|_| |_|\__,_|_|_| |_|\__, | | |
# |___/ | |
server { | |
listen 443; | |
server_name www.lakur.tech; | |
rewrite ^/(.*) https://lakur.tech/$1 permanent; | |
} | |
server { | |
server_name lakur.tech; | |
index index.html; | |
try_files $uri $uri/ =404; | |
listen 443 ssl; | |
ssl_certificate /etc/letsencrypt/live/lakur.tech/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/lakur.tech/privkey.pem; | |
include /etc/letsencrypt/options-ssl-nginx.conf; | |
# Use docker DNS for proxy resolving | |
resolver 127.0.0.11; | |
include /etc/nginx/includes/proxy.conf; | |
set $landing http://production-lakur_landing; | |
location /contact { | |
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-Forwarded-Proto https; | |
proxy_pass http://production-lakur_landing-backend:3000; | |
} | |
location / { | |
proxy_pass $landing; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment