Article directory
Nginx proxy_pass forwarding rule configuration
/api1/
>> http://ip:port
http://localhost/api1/xxx
>>http://localhost:8080/api1/xxx
server {
listen 80;
location /api1/ {
proxy_pass http://localhost:8080;
}
}
/api1/
>>http://ip:port/
http://localhost/api2/xxx
>>http://localhost:8080/xxx
server {
<!--listen 80;-->
location /api2/ {
proxy_pass http://localhost:8080/;
}
}
/api3
>>http://ip:port
http://localhost/api3/xxx
>>http://localhost:8080/api3/xxx
server {
listen 80;
location /api3 {
proxy_pass http://localhost:8080;
}
}
/api4
>>http://ip:port/
http://localhost/api4/xxx
>>http://localhost:8080//xxx
Note: This is a double slash
8080//xxx
, I don’t know if it can be accessed
server {
listen 80;
location /api4 {
proxy_pass http://localhost:8080/;
}
}
/api5/
>>http://ip:port/haha
http://localhost/api5/xxx
>>http://localhost:8080/hahaxxx
Note: There
hahaxxx
is no diagonal bar between
server {
listen 80;
location /api5/ {
proxy_pass http://localhost:8080/haha;
}
}
/api6/
>>http://ip:port/haha/
http://localhost/api6/xxx
>>http://localhost:8080/haha/xxx
Note
api5
the difference between
server {
listen 80;
location /api6/ {
proxy_pass http://localhost:8080/haha/;
}
}
/api7
>>http://ip:port/haha
http://localhost/api7/xxx
>>http://localhost:8080/haha/xxx
server {
listen 80;
location /api7 {
proxy_pass http://localhost:8080/haha;
}
}
/api8
>>http://ip:port/haha/
http://localhost/api8/xxx
>>http://localhost:8080/haha//xxx
NOTE:
haha//xxx
This double diagonal bar
server {
listen 80;
location /api8 {
proxy_pass http://localhost:8080/haha/;
}
}