server {
# 端口,域名/ip
listen 80;
server_name ip;
# 开启gzip压缩配置
# gzip config
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
# 增加ssl
# ssl on; #如果强制HTTPs访问,这行要打开
ssl_certificate /ssl/xxx.com.pem;
ssl_certificate_key /ssl/xxx.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# 指定密码为openssl支持的格式
ssl_protocols TLSv1.2;
# 密码加密方式
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
# 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
ssl_prefer_server_ciphers on;
# 限制请求体大小,一般影响上传文件大小
client_max_body_size 100m;
# 二级目录部署vue前端
location /rwdb {
alias /usr/share/nginx/html/rwdb/;
try_files $uri $uri/ /rwdb/index.html?$query_string;
index index.html;
}
# 二级目录部署springboot转发
location /rwdb/jeecg-boot/ {
proxy_pass http://ip:8081/jeecg-boot/;
proxy_set_header Host ip;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Nacos转发
location /nacos {
proxy_pass http://ip:8848/nacos;
}
# Adminer转发
location /adminer {
proxy_pass http://ip:8080/;
}
# plumelog转发
location /plumelog/ {
proxy_pass http://ip:8891/;
}
# rabbitmq转发
location /rabbitmq/ {
proxy_pass http://ip:15672/;
}
# 根目录部署springboot转发
location ^~ /sxyxfs-boot/ {
proxy_pass http://ip:9999/;
proxy_set_header Host ip;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 根目录部署vue前端解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题
location / {
root /usr/share/nginx/html/back;
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html?s=$1 last;
break;
}
}
}
# To Be Continued!😎
← Nginx常见问题 VMware常见问题 →