需求
將准備好的域名使用Nginx反向代理,通過 域名 來訪問服務器上的IP:8581
准備工作
系統環境 Ubuntu18.04
工具版本 Nginx/1.14.0 (Ubuntu)
服務器外網IP:114.215.183.37 (假設)
域名: kumatazz.net(假設)
Linux下配置
1. 服務器Linux系統下編寫域名配置信息文件
cd /etc/nginx/sites-enabled
vim kumatazz.net
如下內容:
server { server_name kumatazz.net; listen 80; location / { proxy_redirect off; proxy_pass http://127.0.0.1:8581; // 不寫IP地址訪問速度更快 proxy_http_version 1.1; } }
2. 查看nginx.conf文件
確認配置有沒有將上一步的文件include進來:
vim /etc/nginx/nginx.conf // 一般來說已經有include了,沒有則加上去 include /etc/nginx/sites-enabled/*;
3. 重啟nginx服務器
sudo systemctl restart nginx
done !