赞
踩
1.安装依赖包
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2.下载并解压安装包
下载地址 请选择需要的版本如:http://nginx.org/download/nginx-1.18.0.tar.gz
- cd /usr/local//下载tar包
- tar -xvf nginx-1.18.0.tar.gz
3.安装nginx
进入nginx目录(/usr/local 此次是自行选择的解压后目录)
cd /usr/local/nginx-1.18.0
4.编译 make&make install
SSL模块 请使用
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
不使用 SSL模块请使用
--prefix=/usr/local/nginx --with-http_stub_status_module
配置完成后,运行命令
- make
- make install
三、配置(编辑配置文件)
vi /usr/local/nginx/conf/nginx.conf
普通前端页面配置
- server {
- listen 81;
- server_name 127.0.0.1; #服务端地址
-
- location / {
- root html;
- index index.html index.htm;
- }
- }
Https证书配置及转发前端页面
- server {
- listen 443 ssl;
- server_name www.****.net;
-
- ssl_certificate 5437721_www.****.net.pem;
- ssl_certificate_key 5437721_www.****.net.key;
-
- ssl_session_cache shared:SSL:1m;
- ssl_session_timeout 5m;
-
- ssl_ciphers HIGH:!aNULL:!MD5;
- ssl_prefer_server_ciphers on;
-
- location / {
- proxy_pass http://127.0.0.1:81;
- proxy_redirect off;
- }
- }
转发后台配置
- location ~ ^/(VehcApply/Add|VehcApply/Pass|User/)$ {
- proxy_pass http://127.0.0.1:18763;
- proxy_connect_timeout 5s;
- proxy_redirect off;
- #proxy_read_timeout 20s;
- client_max_body_size 100m;#文件上传大小限制
- proxy_send_timeout 5s;
- # 传递真实IP到后竿 proxy_set_header Host $host:$server_port;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
四、启动
- # 检查配置文件
- /usr/local/nginx/sbin/nginx -t
- #启动
- /usr/local/nginx/sbin/nginx
- # 重启加载配置
- /usr/local/nginx/sbin/nginx -s reload
五、验证
访问 *****:81 (外网请开端口)
注意:./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module Https的关键
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。