How to set reverse proxy for special path in nginx?
In my Nignx's default.conf:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
# root /usr/share/nginx/html;
root /var/www/html/website;
index index.html index.htm;
try_files $uri $uri/ /index.html;
proxy_pass http://107.120.30.76:8001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
I only know how to config the / root directory, how can I config the special path?
such as I request the http://107.120.30.76/api/* I want to transfer to http://107.120.30.76:8000/api/*. How to config this?