CentOS安装、配置Nginx反向代理

  • 添加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;
}
}
上一篇:安装 macbook 双系统( OS X 和 Ubuntu )


下一篇:微信公众号DOM的一个坑