0
点赞
收藏
分享

微信扫一扫

nginx请求转发备注


我想根据请求的地址来做转发:
比如请求:www.mydomon.com/scm_sample 那么扔到另一台机器上.

server { 

 listen 80; 

 server_name wwww.hupun.com; 


 #charset koi8-r; 


 #access_log logs/host.access.log main; 


 location ~ ^/scm/(images|pages|javascript|js|css|flash|media|static)/ { 

 root /home/apache-tomcat-7.0.22/webapps; 

 # expires 30d; 

 } 


 location ~ ^/scm/(.*.jpg|.*.gif|.*.png|.*.bmp)/ { 

 root /home/apache-tomcat-7.0.22/webapps; 

 } 


 location /scm { 

 index sys.index.d; 

 proxy_pass http://127.0.0.1:8080$request_uri; 

 } 


 [color=orange]location /scm_sample { 

 set $fixed_destination $http_destination; 

 if ($http_destination ~* ^https(.*)$){ 

 set $fixed_destination http$1; 

 } 

 proxy_set_header Host $host; 

 proxy_set_header X-Real-IP $remote_addr; 

 proxy_set_header Destination $fixed_destination; 

 proxy_pass http://111.11.111.111$request_uri; 


 }[/color]




------------------------------根据访问地址确定访问应用----------------------------------

server{ 

 listen 80; 

 server_name tcrm.hupun.com; 


 location / { 

 proxy_pass http://127.0.0.1:5180/; 

 proxy_set_header Host $host; 

 proxy_set_header X-Real-IP $remote_addr; 

 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 


 } 


 location /crm.open { 

 index index.html; 

 proxy_pass http://127.0.0.1:8380/; 

 proxy_set_header Host $host; 

 proxy_set_header X-Real-IP $remote_addr; 

 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 

 } 


}

举报

相关推荐

0 条评论