文章做者:luxianghaohtml
文章來源:http://www.cnblogs.com/luxianghao/p/6807081.html 轉載請註明,謝謝合做。nginx
免責聲明:文章內容僅表明我的觀點,若有不當,歡迎指正。正則表達式
syntax: rewrite regex replacement [flag] Default: — Context: server, location, if
rewrite ^/users/(.*)$ /show?user=$1? last;=
Syntax: proxy_pass URL; Default: — Context: location, if in location, limit_except
proxy_pass http://localhost:8000/uri/;
upstream backend { server backend1.example.com weight=5; server backend2.example.com:8080; server unix:/tmp/backend3; server backup1.example.com:8080 backup; server backup2.example.com:8080 backup; } server { location / { proxy_pass http://backend; } }
proxy_pass http://$host$uri;
server { listen 80; server_name example.com; proxy_read_timeout 120; proxy_send_timeout 120; include /etc/nginx/fastcgi_params; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; location / { ... } }
location /name/ { proxy_pass http://127.0.0.1/remote/; } 請求http://example.com/name/test.html 會被代理到http://127.0.0.1/remote/test.html
location /name/ { proxy_pass http://127.0.0.1; } 請求http://example/name/test.html 會被代理到http://127.0.0.1/name/test.html
location /name/ { rewrite /name/([^/]+) /users?name=$1 break; proxy_pass http://127.0.0.1; }