ip有端口号如何设置域名?
方法:nginx根据访问域名代理转发
在服务器安装nginx
sudo yum install -y nginx
修改配置文件后重载nginx
vim /etc/nginx/nginx.conf
编辑文件添加转发
编辑文件添加转发,自行修改下面参考样例中的 ip,port,域名,二级域名。
server {
listen 80;
listen [::]:80;
server_name 二级域名.域名;
root /usr/share/nginx/html;
# 这里ip和端口均写公网,表示转发请求到 http://ip:port/
location /{
proxy_pass http://ip:port/;
}
error_page 404 /404.html;
location = /40x.html {}
error_page 500 502 503 504 /50x.html;
location = /50x.html {}
}
重载nginx
nginx -s reload
Do not communicate by sharing memory; instead, share memory by communicating.

浙公网安备 33010602011771号