nginx 安装以及 https +tomcat代理配置

版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/weixin_43841760/article/details/86608996

一、安装nginx
1、将下载好的nginx-1.9.9.tar.gz上传至/usr/local目录,并解压

cd /usr/local
tar -zxvf nginx-1.9.9.tar.gz

2、切换到目录 ,执行脚本,并添加https模块

cd /usr/local/nginx-1.9.9
 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

3、编译,以及安装

make
make install

4、测试

cd /usr/local/nginx/sbin
./nginx -t

在这里插入图片描述
如图显示successful,说明安装成功。

二、配置https+tomcat代理
tomcat使用8080端口,nginx监听443端口
将证书文件上传至/usr/local/nginx/conf目录
server.crt
server.rsa
修改nginx.conf文件,具体配置如下

worker_processes 1;
events {
    worker_connections 1024;
}
http {
    include mime.types;
    default_type application / octet - stream;
    sendfile on;
    keepalive_timeout 65;
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
    server {
        server_name localhost;
        listen 443 ssl;
        ssl_certificate server.crt;
        ssl_certificate_key server.rsa;
        ssl_session_cache shared: SSL: 10m;
        ssl_session_timeout 5m;
        ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH !RC4";
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        location / {
            proxy_pass http: //localhost:8080;
            proxy_set_header X - Forwarded - For $proxy_add_x_forwarded_for;
            proxy_set_header X - Forwarded - Proto $scheme;
            proxy_set_header X - Forwarded - Port $server_port;
            client_max_body_size 1000m;
        }
        location / nginx_status {
            stub_status on;
            access_log off;
        }
        location / test.exe {
            root test;
            autoindex on;
        }
        error_page 500 502 503 504 / 50x.html;
        location = /50x.html {
            root   html;
        } 
    }
}

启动nginx以及重启

./nginx
./nginx -s reload

猜你喜欢

转载自blog.csdn.net/weixin_43841760/article/details/86608996
今日推荐