Intro Nginx Location Rewrite Setting

Intro Nginx Location Rewrite Setting

這篇介紹Nginx Location Rewrite Setting.

How to set redirect?

From http://192.168.1.1/aaa/123 To http://172.1.0.1/123

Nginx Setting:
location /aaa/123/ {
rewrite /aaa/(.*) /$1 break;
proxy_pass http://192.168.1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}