安装nginx:
curl -o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx.rpm
yum install nginx
启动nginx:
systemctl start nginx
激活服务:
systemctl enable nginx
防火墙开放80端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld
修改nginx配置文件:
vi /etc/nginx/conf.d/default.conf
内容如下:
server { listen 80; location / { proxy_pass http://localhost:9888; 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; } }
SELinux白名单:
yum install policycoreutils-python
sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
sudo semodule -i mynginx.pp
重启nginx:
nginx –s reload
浏览器输入:http://192.168.136.138/ ,正常访问9888端口的网站
时间: 2024-10-29 10:46:10