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 ;
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的更多相关文章
- CentOS 7 配置 nginx php-fpm 详细教程
CentOS 7 配置 Nginx 的步骤如下: 首先更新 yum,没有安装 yum 的自行安装 yum update 1. 安装 Nginx yum install nginx 开启 Nginx 并 ...
- 【CentOs】配置nginx
参考资料:http://nginx.org/en/linux_packages.html#stable 1.添加nginx.repo 2.配置nginx 3.启动nginx 1.添加nginx.rep ...
- CentOS 7 配置nginx并默认强制使用https对http进行跳转
1.安装nginx yum install nginx 2.启动nginx服务 service nginx start 3.开启防火墙80端口,云服务器和本地虚拟服务器各有不同,不再赘述. 4.访问你 ...
- centos下配置nginx支持php
添加nginx 默认主页index.php vim .../etc/nginx/conf.d/default.conf location / { root /usr/share/nginx/htm ...
- CentOS 中 配置 Nginx 支持 https
一.基础设置: .yum -y update .yum -y install openssl* .cd /usr/local/nginx/conf .mkdir ./ssl .cd ./ssl # 在 ...
- CentOS下配置nginx conf/koi-win为同一文件的各类错误
今天配置CentOS6.5下安装Nginx + php7 + mysql5.7.15遇到了一些坑.本来家里的电脑在配置环境的时候没有问题,拿去公司的电脑上就是到处报错.不知道是不是人品问题.今晚在家重 ...
- 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 ...
- CentOS 7 配置 Nginx 正向代理 http、https 最详解
手头项目中有使用到 nginx,因为使用的三方云服务器,想上外网需要购买外网IP的,可是有些需要用到外网却不常用的主机也挂个外网IP有点浪费了,便想使用nginx的反向代理来实现多台内网服务器使用一台 ...
- CentOS安装配置nginx和php
今天买了台阿里云服务器用于日常开发测试(新人9块钱半年).系统版本CentOS 6.5 64位. 首先安装nginx: yum install nginx 参考文档: 在CentOS 6上搭建LNMP ...
随机推荐
- jq 笔记
http://bbs.miaov.com/forum.php?mod=forumdisplay&fid=40 2014.10.10jquery 2.0 不兼容ie 6 7 8,以上更适合做移动 ...
- JConsole使用手冊具体解释
一篇Sun项目主页上介绍JConsole使用的文章,前段时间性能測试的时候大概翻译了一下以便学习,今天整理一下发上来.有些地方也不知道怎么翻,就保留了原文,可能还好理解点.呵呵,水平有限,翻的不好,大 ...
- nginx源代码分析--框架设计 & master-worker进程模型
Nginx的框架设计-进程模型 在这之前,我们首先澄清几点事实: nginx作为一个高性能server的特点.事实上这也是全部的高性能server的特点,依赖epoll系统调用的高效(高效是相对sel ...
- leetcode 217 Contains Duplicate 数组中是否有反复的数字
Contains Duplicate Total Accepted: 26477 Total Submissions: 73478 My Submissions Given an array o ...
- SoapUI项目书写自我规范
-->Assertions 判断某个节点存在(_input_name, _button_name) -->Resource 文件夹命名 值去掉红色部分信息 https://mercury- ...
- YTU 2774: Prepare for CET6
2774: Prepare for CET6 时间限制: 1 Sec 内存限制: 128 MB 提交: 40 解决: 37 题目描述 Hard to force the CET4&6 is ...
- 【NYOJ42】一笔画问题
一笔画问题 时间限制:3000 ms | 内存限制:65535 KB 难度:4 Position:http://acm.nyist.net/JudgeOnline/problem.php?pid= ...
- codeforces 939F 单调队列优化dp
F. Cutlet time limit per test 4 seconds memory limit per test 256 megabytes input standard input out ...
- 47. Ext.form.Field.prototype.msgTarget
转自:https://blog.csdn.net/a1542aa/article/details/24295791 ExtJS.form中msgTarget Ext表单提示方式:msgTarget:有 ...
- PCB 规则引擎之JSON对象查看器
在PCB规则引擎开发中,JavaScript V8引擎是处理业务逻辑的, 当然业务逻辑需要数据支撑才行, 即需有将数据推进入到V8引擎.目前这边数据传输到JavaScript V8引擎以C# Mod ...