博客
关于我
Nginx系列6之-rewirte功能使用案例总结
阅读量:794 次
发布时间:2023-02-15

本文共 3259 字,大约阅读时间需要 10 分钟。

?????Nginx???????????

??????

????????????????????????????????

![??????????????]

????

??????????????Nginx?location??

server {    listen       80;    server_name  xxx.com;    location / {        proxy_pass http://127.0.0.1:8000/;        proxy_set_header  Host $host;        proxy_set_header  X-Real-IP  $remote_addr;        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;        client_max_body_size 100m;        client_body_buffer_size 128k;        proxy_connect_timeout 300;        proxy_send_timeout 300;        proxy_read_timeout 300;        proxy_buffer_size 4k;        proxy_buffers 4 32k;        proxy_busy_buffers_size 64k;        proxy_temp_file_write_size 64k;        add_header X-Frame-Options SAMEORIGIN;    }    location /goa {        proxy_pass http://127.0.0.1:8090/;        proxy_set_header  Host $host;        proxy_set_header  X-Real-IP  $remote_addr;        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;        client_max_body_size 100m;        client_body_buffer_size 128k;        proxy_connect_timeout 300;        proxy_send_timeout 300;        proxy_read_timeout 300;        proxy_buffer_size 4k;        proxy_buffers 4 32k;        proxy_busy_buffers_size 64k;        proxy_temp_file_write_size 64k;        add_header X-Frame-Options SAMEORIGIN;    }}

??????

?????????xxx.com/goa??????CSS?JS???????????????????????/goa?????????????????Nginx????????location?????????

server {    listen       80;    server_name  xxx.com;    location / {        proxy_pass http://127.0.0.1:8000/;        proxy_set_header  Host $host;        proxy_set_header  X-Real-IP  $remote_addr;        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;        client_max_body_size 100m;        client_body_buffer_size 128k;        proxy_connect_timeout 300;        proxy_send_timeout 300;        proxy_read_timeout 300;        proxy_buffer_size 4k;        proxy_buffers 4 32k;        proxy_busy_buffers_size 64k;        proxy_temp_file_write_size 64k;        add_header X-Frame-Options SAMEORIGIN;    }    location /goa {        proxy_pass http://127.0.0.1:8090/;        proxy_set_header  Host $host;        proxy_set_header  X-Real-IP  $remote_addr;        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;        client_max_body_size 100m;        client_body_buffer_size 128k;        proxy_connect_timeout 300;        proxy_send_timeout 300;        proxy_read_timeout 300;        proxy_buffer_size 4k;        proxy_buffers 4 32k;        proxy_busy_buffers_size 64k;        proxy_temp_file_write_size 64k;        add_header X-Frame-Options SAMEORIGIN;    }    location ~  ^(/css/|/Scripts/|/site/|/images/) {        if ($host = "xxx.com") {            rewrite ^/css/(.*)   /goa/css/$1 last;            rewrite ^/site/(.*)    /goa/site/$1 last;            rewrite ^/Scripts/(.*)   /goa/Scripts/$1 last;            rewrite ^/images/(.*)   /goa/images/$1 last;        }    }}

????

  • location ~ ^(/css/|/Scripts/|/site/|/images/)??????/css/?/Scripts/?/site/?/images/??????
  • rewrite????????????????????/goa??????
  • last????????????????????????

????????

????????????????????????Nginx?

nginx -t

??????Nginx?????????

????

  • ????CSS?JS????/goa/css/?/goa/Scripts/?????
  • ???????????????????????

???????????????????????????????????????

转载地址:http://pzjfk.baihongyu.com/

你可能感兴趣的文章
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
Nginx 负载均衡配置详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置dist 加上跨域配置
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置服务器文件上传与下载
查看>>
Nginx 配置清单(一篇够用)
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
Nginx 集成Zipkin服务链路追踪
查看>>
nginx 集群配置方式 静态文件处理
查看>>
Nginx+Django-Python+BPMN-JS的整合工作流实战项目
查看>>
Nginx+Keepalived+LVS集群实战
查看>>
Nginx+Keepalived实现简单版高可用主备切换
查看>>
Nginx+Lua 开发高性能Web应用实战
查看>>
nginx+mysql+redis+mongdb+rabbitmq 自动化部署脚本
查看>>
nginx+php的搭建
查看>>
nginx+tomcat+memcached
查看>>
nginx+tomcat单个域名及多个域名配置
查看>>