CentOS系统下,配制nginx代理

1、安装:

  yum install nginx

2、证书文件位置:

  a. 创建https证书文件夹:/etc/nginx/ssl

  b. 上传两个证书文件到/etc/nginx/ssl

 

3、在/etc/nginx/conf.d创建default.conf( MacOS默认是/usr/local/etc/nginx/nginx.conf),

  配制内容如下:

upstream cms{
server 127.0.0.1:80;
}

server {
listen 443 ssl;
server_name hongdong.tech;
root /usr/share/nginx/html;

ssl on;
ssl_certificate /etc/nginx/ssl/hongdong.tech.pem;
ssl_certificate_key /etc/nginx/ssl/hongdong.tech.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {

proxy_set_header Host $host;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://cms;
}

#location /party_web 中的 party_web 为网站访问路径
location /party_web {
alias /usr/local/nginx/webapps/party_web/;
#使用alias方式,party_web 后面必须跟 “/”
#/usr/local/nginx/webapps/party_web/ 为前端项目包的实际存放路径
index index.html index.htm;
}
}

4、启动、重启

  #启动

  >sudo nginx

  #重启

  >nginx -s reload

  快速停止命令 sudo nginx -s stop

  平稳退出命令:sudo nginx -s quit

posted @ 2019-07-04 14:01  风别鹤  阅读(587)  评论(0编辑  收藏  举报