安装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 ;
server_name domain.com www.domain.com;

  location / {
    proxy_pass http://localhost:9888;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  }

}

proxy_set_header Connection "upgrade";   表示支持websocket

nginx代理的websocket,如果1分钟内没有任何通讯,websocket会自动端口,所以可以考虑20秒做个心跳包,或者有个比较好的断开自动重连的机制

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端口的网站

server_name配置规则参考(支持正则表达式):

server_name  domain.com  www.domain.com;
server_name  *.domain.com;
 server_name  www.*;
server_name  ~^(?.+)\.domain\.com$;

centos 7 配置nginx的更多相关文章

  1. CentOS 7 配置 nginx php-fpm 详细教程

    CentOS 7 配置 Nginx 的步骤如下: 首先更新 yum,没有安装 yum 的自行安装 yum update 1. 安装 Nginx yum install nginx 开启 Nginx 并 ...

  2. 【CentOs】配置nginx

    参考资料:http://nginx.org/en/linux_packages.html#stable 1.添加nginx.repo 2.配置nginx 3.启动nginx 1.添加nginx.rep ...

  3. CentOS 7 配置nginx并默认强制使用https对http进行跳转

    1.安装nginx yum install nginx 2.启动nginx服务 service nginx start 3.开启防火墙80端口,云服务器和本地虚拟服务器各有不同,不再赘述. 4.访问你 ...

  4. centos下配置nginx支持php

    添加nginx 默认主页index.php vim .../etc/nginx/conf.d/default.conf location / { root   /usr/share/nginx/htm ...

  5. CentOS 中 配置 Nginx 支持 https

    一.基础设置: .yum -y update .yum -y install openssl* .cd /usr/local/nginx/conf .mkdir ./ssl .cd ./ssl # 在 ...

  6. CentOS下配置nginx conf/koi-win为同一文件的各类错误

    今天配置CentOS6.5下安装Nginx + php7 + mysql5.7.15遇到了一些坑.本来家里的电脑在配置环境的时候没有问题,拿去公司的电脑上就是到处报错.不知道是不是人品问题.今晚在家重 ...

  7. linux(centos)上配置nginx、mysql、php-fpm、redis开机启动<转>

    原文 http://levi.cg.am/archives/2925 I.nginx开机启动 在/etc/init.d/目录下创建脚本 1 vi  /etc/init.d/nginx 更改脚本权限 1 ...

  8. CentOS 7 配置 Nginx 正向代理 http、https 最详解

    手头项目中有使用到 nginx,因为使用的三方云服务器,想上外网需要购买外网IP的,可是有些需要用到外网却不常用的主机也挂个外网IP有点浪费了,便想使用nginx的反向代理来实现多台内网服务器使用一台 ...

  9. CentOS安装配置nginx和php

    今天买了台阿里云服务器用于日常开发测试(新人9块钱半年).系统版本CentOS 6.5 64位. 首先安装nginx: yum install nginx 参考文档: 在CentOS 6上搭建LNMP ...

随机推荐

  1. 【CV论文阅读】Rank Pooling for Action Recognition

    这是期刊论文的版本,不是会议论文的版本.看了论文之后,只能说,太TM聪明了.膜拜~~ 视频的表示方法有很多,一般是把它看作帧的序列.论文提出一种新的方法去表示视频,用ranking function的 ...

  2. 七、备忘录模式Memento(行为型模式)

    其目的是,在不违反封装原则的前提下.採集和备份一个对象的内部状态以便这个对象能够在以后恢复到之前的某个状态. 在Memento模式中,有例如以下角色: 1.Memento (备忘录) * 存储Orig ...

  3. JSP开发学习参考文章

    配置JDK和Tomcat环境变量 http://blog.csdn.net/lijiazhi1987/article/details/2742181 eclipse maven plugin 插件安装 ...

  4. ZOJ 2397:Tian Ji -- The Horse Racing

    Tian Ji -- The Horse Racing Time Limit: 5 Seconds      Memory Limit: 32768 KB Here is a famous story ...

  5. 【POJ 2259】 Team Queue

    [题目链接] http://poj.org/problem?id=2259 [算法] 由题,一个人入队时,若这个人所在的组已经有人在队列中,则加入队列,否则排到队末 因此我们发现,这个队列一定是由连续 ...

  6. 【POJ 2965】 The Pilots Brothers' refrigerator

    [题目链接] http://poj.org/problem?id=2965 [算法] 位运算 [代码] #include <algorithm> #include <bitset&g ...

  7. Python3基础复习

    目录 基本语法 运算符 输出格式 数据类型 数据结构 函数 面向对象 补充 异常 模块和包 文件 时间 线程和进程 基本语法 基本语法只列举与Java不一样的. 运算符 and, or而非 & ...

  8. NET运用String的十八层境界

    古往今来,文本处理一直是所有编程语言的最基础的功能,也是最核心最重要的功能.任何初学者,如果想学一门编程语言,都要面对大量的文本处理.而或许有一天,即使你成了大师级的人物,也不敢说自己驾驭文本处理的能 ...

  9. Linux扩展正则表达式

    1. 扩展正则表达式 1.1 +(加号) + 表示前一个字符出现1次或1次以上 1.1.1 理解+ 要求:取出文件内容连续出现的小写字母 [root@oldboyedu50-lnb /oldboy]# ...

  10. codevs 2541 幂运算(迭代加深搜索)

    2541 幂运算  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 从m开始,我们只需要6次运算就可以计算出m31 ...