nginx 靜態資源轉發
阿新 • • 發佈:2020-12-22
NGINX 代理轉發,NGINX 靜態資源轉發
通過nginx代理靜態資源(js/css 等)
spring boot 建立web應用時請求URL無法訪問樣式問題?
nginx 轉發代理 Spring-boot 提示 Whitelabel Error Page 處理方式
Css樣式引入和靜態資源存放在assets,後端上傳的資源存放在public
nginx 代理轉發示例:
server { listen 80; server_name css.test.cn; charset utf-8; client_max_body_size 35m;
# nginx 代理轉發後端服務 location/ { proxy_pass http://172.16.2.18:8001/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
# 靜態資源轉發配置
location ~ .*\.(js|css|jpg|jpeg|gif|png|ico|pdf|txt)$ { proxy_pass http://172.16.2.18:8001; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Accept-Encoding ""; sub_filter_types *; sub_filter_once off; sub_filter 'indexTips' 'indexTips1'; } }
重啟 Nginx 程序