- 添加Nginx存儲庫
sudo yum install epel-release
- 安裝Nginx
sudo yum install nginx
- 啟動Nginx
sudo systemctl start nginx
- 如果正在運行防火牆,運行以下命令以允許HTTP和HTTPS通信
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
- 在系統啟動時啟用Nginx
sudo systemctl enable nginx
- 配置Nginx '/etc/nginx/nginx.conf'
server { listen 80;//監聽端口號 server_name example.com *.example.com; location / { proxy_pass http://localhost:5000;//轉發到 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade; } }