Last active
March 12, 2019 23:13
-
-
Save Hujun/0bd2d2ab8a9626511edff7d4da7b93f2 to your computer and use it in GitHub Desktop.
Rancher(v1.6) + Nginx docker deployment config
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: "2" | |
services: | |
rancher: | |
image: rancher/server:stable | |
container_name: "rancher-server" | |
restart: always | |
ports: | |
- "8080:8080" | |
volumes: | |
- ./rancher/mysql:/var/lib/mysql | |
nginx: | |
image: nginx:latest | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- ./nginx/config:/etc/nginx:ro | |
- ./nginx/log:/var/log/nginx | |
container_name: "nginx" | |
restart: always |
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
# For more information on configuration, see: | |
# * Official English Documentation: http://nginx.org/en/docs/ | |
# * Official Russian Documentation: http://nginx.org/ru/docs/ | |
user nginx; | |
worker_processes auto; | |
error_log /var/log/nginx/error.log; | |
pid /run/nginx.pid; | |
# Load dynamic modules. See /usr/share/nginx/README.dynamic. | |
include /usr/share/nginx/modules/*.conf; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
map $http_upgrade $connection_upgrade { | |
default Upgrade; | |
'' close; | |
} | |
include /etc/nginx/mime.types; | |
include /etc/nginx/proxy.conf; | |
default_type application/octet-stream; | |
# Load modular configuration files from the /etc/nginx/conf.d directory. | |
# See http://nginx.org/en/docs/ngx_core_module.html#include | |
# for more information. | |
include /etc/nginx/conf.d/*.conf; | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
server_name _; | |
# force use ssl | |
return 307 https://$host$request_uri; | |
# root /usr/share/nginx/html; | |
# Load configuration files for the default server block. | |
# include /etc/nginx/default.d/*.conf; | |
# location / { | |
# } | |
# error_page 404 /404.html; | |
# location = /40x.html { | |
# } | |
# error_page 500 502 503 504 /50x.html; | |
# location = /50x.html { | |
# } | |
} | |
# Settings for a TLS enabled server. | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name _; | |
root /usr/share/nginx/html; | |
ssl_certificate <ssl certifacate file location>; | |
ssl_certificate_key <ssl key file location>; | |
ssl_session_cache shared:SSL:1m; | |
ssl_session_timeout 5m; | |
ssl_ciphers <ssl cipher>; | |
ssl_prefer_server_ciphers on; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
# Load configuration files for the default server block. | |
include /etc/nginx/default.d/*.conf; | |
location / { | |
} | |
error_page 404 /404.html; | |
location = /40x.html { | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} | |
} |
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
proxy_redirect off; | |
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 $scheme; | |
proxy_set_header X-Forwarded-Port $server_port; | |
proxy_set_header Upgrade $http_upgrade; | |
# variable `connection_upgrade` defined in nginx.conf | |
proxy_set_header Connection $connection_upgrade; | |
client_max_body_size 10m; | |
client_body_buffer_size 128k; | |
proxy_connect_timeout 90; | |
proxy_send_timeout 90; | |
proxy_read_timeout 90; | |
proxy_buffers 32 4k; |
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
# under conf.d/ | |
upstream rancher { | |
server rancher-server:8080; | |
} | |
server { | |
listen 80; | |
server_name rancher.hexcloud.cn; | |
return 307 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name rancher.hexcloud.cn; | |
root /usr/share/nginx/html; | |
ssl_certificate <ssl certifacate file location>; | |
ssl_certificate_key <ssl key file location>; | |
ssl_session_cache shared:SSL:1m; | |
ssl_session_timeout 5m; | |
ssl_ciphers <ssl cipher>; | |
ssl_prefer_server_ciphers on; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
# Load configuration files for the default server block. | |
include /etc/nginx/default.d/*.conf; | |
location / { | |
proxy_pass http://rancher; | |
# This allows the ability for the execute shell window to remain open for up to 15 minutes. | |
# Without this parameter, the default is 1 minute and will automatically close. | |
proxy_read_timeout 900s; | |
proxy_http_version 1.1; | |
} | |
error_page 404 /404.html; | |
location = /40x.html { | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment