nginx做端口映射
时间: 2023-08-24 13:14:38 浏览: 111
nginx可以通过配置文件来实现端口映射。在nginx的配置文件中,可以使用`listen`指令来指定监听的端口号。例如,如果想要将80端口映射到8080端口,可以在配置文件中添加以下内容:
```
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
```
在这个配置中,`listen 80;`表示监听80端口,`proxy_pass http://127.0.0.1:8080;`表示将请求转发到本地的8080端口。这样,当访问80端口时,nginx会将请求转发到8080端口上。请注意,`server_name`指令用于指定域名,如果没有域名,可以将其改为`localhost`。\[1\]
#### 引用[.reference_title]
- *1* [nginx端口映射 nginx反向代理配置](https://blog.csdn.net/qq_41772384/article/details/124251701)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [如何在Nginx中配置端口映射?花生壳和Nginx的配置使用教程](https://blog.csdn.net/oray2013/article/details/123926475)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文