limit_req_zone $binary_remote_addr zone=allips:10m rate=5r/s;
upstream webser {
server 172.16.238.1:8282; //jar service 服务地址和端口
keepalive 1000;
}
client_max_body_size 100m;//上传限制
server {
listen 443 ssl;
server_name xxx.com www.xx.com;//服务器地址
ssl_certificate /etc/ssl/private/xxpem; //ssl证书
ssl_certificate_key /etc/ssl/private/xx.key; //ssl证书
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;
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]\.";
location /api {
proxy_pass http://webser/;
limit_req zone=allips burst=5;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $remote_addr;
}
location ~* \.(?:jpg|jpeg|png|gif|ico|css|js)$ {
root /usr/share/nginx/www/admin/; //html 代码地址
expires 60s;
add_header Cache-Control "public";
}
location / {
root /usr/share/nginx/www/admin/; //html 代码地址
try_files $uri $uri/ /index.html;
}
}
server {
listen 443 ssl;
server_name xxx.com www.xxx.com;
ssl_certificate /etc/ssl/private/xx.pem;
ssl_certificate_key /etc/ssl/private/xxx.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;
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]\.";
location /api {
proxy_pass http://webser/;
limit_req zone=allips burst=5;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $remote_addr;
}
location ~* \.(?:jpg|jpeg|png|gif|ico|css|js)$ {
root /usr/share/nginx/www/web/; //html 代码地址
expires 60s;
add_header Cache-Control "public";
}
location / {
root /usr/share/nginx/www/web/; //html 代码地址
try_files $uri $uri/ /index.html;
}
}
nginx祖传配置,前后端分离
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 一、项目背景 项目分前后端,前端使用vue,提供web访问;后端使用spring boot,提供数据接口。 服务器...
- 注意: nginx 不支持循环if add_header xxxxx xxxx 内容请放入location内,直接...
- 前提: 后端服务地址为:localhost:8989; 前端页面目录为:/Users/xxxx/dev/xxxx;...