Nginx安装配置项目部署然后加SSL

个人操作笔记记录

第一步:把 nginx 的源码包nginx-1.8.0.tar.gz上传到 linux 系统

第二步:解压缩

tar zxvf nginx-1.8.0.tar.gz

第三步:进入nginx-1.8.0目录   使用 configure 命令创建一 makeFile 文件。

直接复制过去运行

./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi \

--with-http_stub_status_module --with-http_ssl_module

第四步:编译

make

第五步:安装

make install

注意:启动nginx 之前,上边将临时文件目录指定为/var/temp/nginx/client, 需要在/var  下创建此 目录

mkdir /var/temp/nginx/client -p

进入到Nginx目录下的sbin目录

cd /usr/local/ngiux/sbin

输入命令启动Nginx

./nginx

启动后查看进程

ps aux|grep nginx

./nginx 启动

./nginx -s stop 停止 非正常退出

./nginx -s quit 正常退出

./nginx  -s reload 重新加载

接下来我启动了两个应用:

应用1:端口号为8081

应用2:端口号为8082

Nginx配置域名转发

upstream tomcat-travel{
           server 服务器ip127.0.0.1:8081;
    }
    
    upstream tomcat-travel2{
           server 服务器ip127.0.0.1:8082;
    }
    
    server {
        listen       80;
        server_name www.域名1.com;#如www.baidu.com

        location / {
            #root   html;
            proxy_pass http://tomcat-travel;
            index  index.html index.htm;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

     
    }
    
    server {
        listen       80;
        server_name 域名2;#如www.baidu.com
        server_name hnyfsh.com;
        location / {
            #root   html;
            proxy_pass http://tomcat-travel2;
            index  index.html index.htm;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

     
    }

NginxSSL

 server {
    	listen 443 ssl;
    	server_name www.域名.cn;
    
    	ssl_certificate /opt/java/ssl/自己的.cn.pem;
    	ssl_certificate_key /opt/java/ssl/自己的.cn.key;
    
    	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    	ssl_session_cache shared:SSL:10m;
    	ssl_session_timeout 10m;
    
    	location / {
    		proxy_pass http://tomcat-travel2;
    		proxy_set_header Host $host;
    		proxy_set_header X-Real-IP $remote_addr;
    		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    	}
    } 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值