nginx 前端配置
https://blog.csdn.net/zoeou/article/details/89302079
https://blog.csdn.net/xujiamin0022016/article/details/89478490
https://www.cnblogs.com/CSWin/p/14889091.html
https://blog.51cto.com/riverxyz/3883300
https://www.jianshu.com/p/46eb10532ba3
https://blog.csdn.net/qq_52385631/article/details/123905925
https://blog.csdn.net/qq_41604686/article/details/124391662
https://blog.csdn.net/weixin_42322206/article/details/105176786
https://www.cnblogs.com/lwx768561/p/15733464.html
https://blog.csdn.net/sayyy/article/details/115842699
https://www.bbsmax.com/A/8Bz8plX1zx/
网关配置
server {
listen 8003;
server_name dev-returnorder-pc-java-ui.eminxing.com;
#server_name localhost;
access_log logs/dev-access.log main;
# root /data/local/frontend;
index index.html index.htm;
#location / {
# try_files $uri $uri/ @router;
# add_header Cache-Control no-cache;
# add_header Access-Control-Allow-Origin *;
# add_header Access-Control-Allow-Headers *;
# add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
#}
location /web{
proxy_pass http://localhost:8002/;
}
location /web/1returnorder111{
proxy_next_upstream http_502 http_504 error invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header $http_x_forwarded_for $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_buffer_size 64k;
proxy_buffers 4 128k;
proxy_http_version 1.1;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_pass http://localhost:8002/returnorder-pc-java-ui/;
}
#location @router {
# rewrite ^.*$ /index.html last;
# }
location /config.js {
# 基于域名返回指定环境配置
# rewrite .* /dev.config.js;
#return 301 /dev.config.js;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~ /snapshot.info {
deny all;
}
}
location / {
root /usr/share/nginx/html/tuanzi_m;;
index index.html index.htm;
try_files $uri $uri/ @router;
}
location @router {
rewrite ^.*$ /index.html last;
}
server {
listen 8002;
server_name dev-returnorder-pc-java-ui.eminxing.com;
#server_name localhost;
access_log logs/dev-access.log main;
root /data/local/frontend;
index index.html index.htm;
#location ~ /(overseas|returns|returnorder)/ {
location ~ /([^/.]*)/ {
#default_type text/html;
#return 200 "$1";
#try_files $uri $uri/ @router;
try_files $uri $uri/ /$1/index.html last;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers *;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
}
#location /overseas{
#default_type text/html ;
#return 200 "overseas";
# root /data/local/frontend/overseas-pc-java-ui/;
# index index.html index.htm;
# try_files $uri $uri/ /index.html last;
# }
location @router {
rewrite ^.*$ /index.html last;
}
location /config.js {
# 基于域名返回指定环境配置
rewrite .* /dev.config.js;
#return 301 /dev.config.js;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~ /snapshot.info {
deny all;
}
}
https://juejin.cn/post/7089727152882450439
设置 js、css、img 强制缓存
map $sent_http_content_type $expires {
default off;
text/html epoch; # 不缓存
text/css 30d; # 缓存30天,长时缓存可以设置为max
application/javascript 30d;
application/octet-stream 30d;
~image/ 30d;
}
server {
listen 80;
server_name localhost;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
add_header X-Frame-Options SAMEORIGIN;
add_header Access-Control-Allow-Credentials true;
expires $expires; #对不同的资源设置缓存
index index.html;
...
}