往nginx。conf的指定位置 添加新的内容
开始配置文件内容:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location ~ ^/host1/ {
rewrite ^/host1/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8080;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location ~ ^/host1/ {
rewrite ^/host1/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8080;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
我希望达到的效果是
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location ~ ^/host1/ {
rewrite ^/host1/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8080;
}
location ~ ^/host2/ {
rewrite ^/host2/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8080;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location ~ ^/host1/ {
rewrite ^/host1/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8080;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
麻烦 大神 们看看