nginx 学习:将域名转发到本地端口
首先介绍最常用的,将域名转发到本地另一个端口上
server{
listen 80;
server_name tomcat.shaochenfeng.com;
index index.php index.html index.htm;
location / {
proxy_pass http://127.0.0.1:8080; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让8080端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}