Linux 部署 nginx服务代理
2016-11-02 13:21
656 查看
原文地址:http://www.cnblogs.com/ants/p/5732337.html#_label5
参考地址:http://www.cnblogs.com/hustskyking/p/nginx-configuration-start.html
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx
其他的停止nginx 方式:
ps -ef | grep nginx
kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx
启动nginx:
nginx -c /path/to/nginx.conf
平滑重启nginx:
kill -HUP 主进程号
rpm -ivh nginx.rpm
yum install nginx
安装成功!
输入:systemctl start nginx 来启动nginx。
输入:systemctl enable nginx 来设置nginx的开机启动(linux宕机、重启会自动运行nginx不需要连上去输入命令)
命令:systemctl restart firewalld(重启防火墙以使配置即时生效)
测试nginx是否可以访问。
在文件中加入或修改:
执行: nginx -s reload 使其即时生效
运行ASP.NET Core应用程序
这时候再次尝试访问。
这个问题是由于SELinux保护机制所导致,我们需要将nginx添加至SELinux的白名单。
接下来我们通过一些命令解决这个问题。
再次访问
参考地址:http://www.cnblogs.com/hustskyking/p/nginx-configuration-start.html
相关命令:
nginx -s reload :修改配置后重新加载生效nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx
其他的停止nginx 方式:
ps -ef | grep nginx
kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx
启动nginx:
nginx -c /path/to/nginx.conf
平滑重启nginx:
kill -HUP 主进程号
安装Nginx
curl -o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpmrpm -ivh nginx.rpm
yum install nginx
安装成功!
输入:systemctl start nginx 来启动nginx。
输入:systemctl enable nginx 来设置nginx的开机启动(linux宕机、重启会自动运行nginx不需要连上去输入命令)
配置防火墙
命令:firewall-cmd --zone=public --add-port=80/tcp --permanent(开放80端口)命令:systemctl restart firewalld(重启防火墙以使配置即时生效)
测试nginx是否可以访问。
配置nginx对ASP.NET Core应用的转发
修改 /etc/nginx/conf.d/default.conf 文件。在文件中加入或修改:
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 -s reload 使其即时生效
运行ASP.NET Core应用程序
这时候再次尝试访问。
这个问题是由于SELinux保护机制所导致,我们需要将nginx添加至SELinux的白名单。
接下来我们通过一些命令解决这个问题。
yum install policycoreutils-python sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx sudo semodule -i mynginx.pp
再次访问
相关文章推荐
- Linux下squid代理缓存服务环境部署
- Node部署学习-3-Nginx反向代理Node服务
- linux基础 -nginx和nfs代理 开发脚本自动部署及监控
- 一台机器部署多个tomcat服务 nginx反向代理多个服务 笔记
- Linux基础入门教程-使用Squid部署代理缓存服务
- linux企业常用服务---部署NGINX虚拟主机
- Linux下安装高性能nginx服务部署
- cool-2018-02-04-linux nginx代理tomcat 部署javaweb项目
- nginx在linux系统下的安装部署,以及反向代理https请求协议,ssl证书的生成,负载均衡tomcat服务器!
- 【服务器搭建环境配置】Linux上部署Nginx服务以及故障排除
- 通过 Nginx 反向代理部署 Node.js 服务
- 【Linux】Nginx安装、部署--CentOS5.4
- 菜鸟学Linux之三:Linux下用户的集中管理之信息网络服务(NIS)的搭建与部署
- Linux 下Tomcat部署 及 将Tomcat配置成服务
- Linux下部署svn服务
- Linux系列-Red Hat5平台下构建Squid代理服务
- 用linux构建基于mysql,php的nginx服务平台
- [Linux] Ubuntu 下部署 Nginx Flup Django
- NginX ------ Linux下部署资料
- Linux Nginx服务守护监控