nginx反向代理二级域名
时间: 2023-09-09 15:11:29 浏览: 189
Nginx 反向代理
nginx反向代理可以用来解析多个二级域名,从而通过同一个端口访问不同的项目。在nginx配置文件中新增server节点来配置反向代理。例如,在nginx.conf文件中添加以下配置:
server {
listen 80;
server_name jenkins.example.com; //你的二级域名
location / {
proxy_redirect http://jenkins.example.com:8080/ /; //代理重定向地址为二级域名的8080端口
proxy_pass http://127.0.0.1:8080/; //代理的地址主机IP和端口
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
通过以上配置,nginx会将来自jenkins.example.com的请求转发到本地的8080端口上。重启nginx服务后,即可实现通过二级域名访问相应的项目。 <span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [入门Nginx之-反向代理实现二级域名转发](https://blog.csdn.net/u013810234/article/details/89707077)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [nginx 反向代理配置二级域名正确姿势!!!](https://blog.csdn.net/weixin_37680520/article/details/108680407)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文