yum intsall nginx
启动服务
sudo systemctl start nginxsudo firewall-cmd --permanent --zone=public --add-service=http 容许http通讯 sudo firewall-cmd --permanent --zone=public --add-service=https 容许https通讯 sudo firewall-cmd --reload 从新加载配置
在 /etc/nginx/conf.d 目录中新建一个my.conf文件,在此以前先将nginx.conf 配置文件中的server节点注释掉nginx
server {
listen 80; #映射端口 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 $host; proxy_cache_bypass $http_upgrade; } }
执行这两个命令中的任一个重置nginx网络
nginx -s reload 从新加载配置文件
systemctl nginx restart 重启nginx
此时经过80端口访问网站应该是一切正常,但不凡意外发生ide
进入 /var/log/nginx/ 目录中查看错误日志,若是是如下错误,能够尝试用下面的方法解决学习
getsebool -a |grep httpd_can_network_connect //检查http网络访问权限状况
咱们能够看到它是关闭状态的网站
执行 setsebool -P httpd_can_network_connect 1 //开启网络访问权限
开启后 http_can_network_connect 状态为onspa