====== 09 Dockerリバースプロキシ(HTTPS) ======
こちらの方が便利かも[[06_virtualization:05_container:25_let_s_encrypt_proxy]]
この設定で下記のように表示されます。
hogehoge.com -> reverse.com
hogehoge2.com -> reverse2.com
hogehoge3.com -> reverse3.com
===== docker-compose.yml =====
version: '3.3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true
ports:
# nesessary port 80 for Let's Encrypt
- 80:80
- 443:443
volumes:
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro
- ./nginx-proxy/custom.conf:/etc/nginx/conf.d/custom.conf:ro
restart: always
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./certs:/etc/nginx/certs:rw
restart: always
bridge-1:
image: nginx:latest
volumes:
- ./bridge-1/default.conf:/etc/nginx/conf.d/default.conf
- ./bridge-1:/var/www/html
environment:
- VIRTUAL_PORT=80
- VIRTUAL_HOST=hogehoge.com, hogehoge2.com, hogehoge3.com
- LETSENCRYPT_HOST=hogehoge.com, hogehoge2.com, hogehoge3.com
- LETSENCRYPT_EMAIL=info@kumolabo.com
restart: always
volumes:
vhost:
html:
===== ファイル作成 =====
mkdir ./nginx-proxy/
touch ./nginx-proxy/custom.conf
mkdir ./bridge-1/
===== ./bridge-1/default.conf =====
./bridge-1/default.conf
server {
listen 80;
server_name hogehoge.com;
location / {
proxy_request_buffering off;
proxy_pass http://reverse.com/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name hogehoge2.com;
location / {
proxy_request_buffering off;
proxy_pass http://reverse2.com/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name hogehoge3.com;
location / {
proxy_request_buffering off;
proxy_pass http://reverse3.com/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
===== client_max_body_size =====
下記2つのファイルにclient_max_body_sizeを追加する。
echo 'client_max_body_size 1g;' >> ./nginx-proxy/custom.conf
vi ./bridge-1/default.conf
client_max_body_size 1g;
server {
listen 80;
server_name hogehoge.com;
location / {
proxy_request_buffering off;
proxy_pass http://reverse.com/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
{{tag>Docker Proxy}}