最快的方法用Nginx设置端口转发:
以Ubuntu为例:
1.安装:
sudo apt-get install nginx
2./etc/nginx下.找到nginx.conf,赋予权限:
sudo chmod 777 nginx.conf
3.注释掉:#include /etc/nginx/sites-enabled/*; //
4.添加在http{}里
server {
listen 80; #设置默认端口80
server_name localhost;
location / {
proxy_pass http://127.0.0.1:5000; #80端口指向5000端口,本地浏览器打开127.0.0.1:80即可访问:5000
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
5.重启
sudo service nginx restart
本文介绍了用Nginx设置端口转发的最快方法,以Ubuntu系统为例,涵盖安装Nginx、赋予nginx.conf权限、注释配置、添加端口转发规则到http{}中,最后重启Nginx服务,实现将80端口指向5000端口。
172

被折叠的 条评论
为什么被折叠?



