centos 7 配置nginx
Posted IWay
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos 7 配置nginx相关的知识,希望对你有一定的参考价值。
安装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端口的网站
以上是关于centos 7 配置nginx的主要内容,如果未能解决你的问题,请参考以下文章