Nginx 配置
作者:唐亚峰 | battcn
字数统计:280 字
请求头转发
注意
不配置转发自定义请求头的话租户编码不会转发
shell
http {
include mime.types;
default_type application/octet-stream;
# 默认应该是 off , 所以要打开
underscores_in_headers on;
}
HTTP 配置
shell
server {
listen 80;
server_name cloud.battcn.com;
location / {
# vue 静态资源打成tar.gz 包 开启压缩 速度更快
root /opt/wemirr-platform/cloud-ui/dist;
gzip_static on;
}
location /api/ {
proxy_pass http://localhost:9000/;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
HTTPS 配置
shell
server {
listen 80;
server_name cloud.battcn.com;
# 强制跳转 HTTPS
rewrite ^(.*)$ https://cloud.battcn.com;
}
server {
listen 443 ssl;
server_name cloud.battcn.com;
ssl on;
# 证书是从阿里云申请的免费证书
ssl_certificate xxxx.battcn.com.pem;
ssl_certificate_key xxxx.battcn.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
# vue 静态资源打成tar.gz 包 开启压缩 速度更快
root /opt/wemirr-platform/cloud-ui/dist;
gzip_static on;
}
location /api/ {
proxy_pass http://localhost:9000/;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}