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;
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM