Bathing
域名转发到本地
一般的话代理tomcat较多,这里以代理tomcat的8080端口为例:
server{
listen 80;
server_name bathing.com ;
index index.php index.html index.htm;
 
location / {
proxy_pass http://127.0.0.1:8080(bathing.net); //转发规则
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;
}

 

访问 bathing.com 会变成访问本地 http://127.0.0.1:8080 , 转发域名话 将 1270.0.1:8080 改为需要更改的域名即可,如 改为bathing.net 则访问 bathing.com会变成访问 bathing.net
 
 
配置proxy_pass代理转发,如果url加 / , 表示绝对根路径 ; 如果没有 / 表示相对路径
 
1. 加 /
server_name bathing.com;
index index.php index.html index.htm;
local /data/ {
proxy_pass http://127.0.0.1/;
}

 

访问 bathing.com/data/index.html 会转发 http://127.0.0.1/index.html
 
2. 不加 /
server_name bathing.com
local /data/ {
proxy_pass http://127.0.0.1;
}

 

访问 bathing.com/data/index.html 会转发 http://127.0.0.1/data/index.html
 

分类:

技术点:

相关文章:

  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-10-22
  • 2021-07-31
  • 2021-09-17
  • 2022-01-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-08
  • 2021-11-23
相关资源
相似解决方案