nginx+tomcat配置https

本文详细介绍了如何在Nginx中安装并配置http_ssl_module模块,包括使用./configure命令进行配置、编译安装过程及如何正确替换原有Nginx二进制文件。同时,还提供了配置HTTPS监听及代理Tomcat的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

nginx安装./configure --with-http_ssl_module模块, 

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

那么我们的新配置信息就应该这样写:

1

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

运行上面的命令即可,等配置完

配置完成后,运行命令

1

make

这里不要进行make install,否则就是覆盖安装

然后备份原有已安装好的nginx

1

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

然后将刚刚编译好的nginx覆盖掉原有的nginx(这个时候nginx要停止状态)

1

cp ./objs/nginx /usr/local/nginx/sbin/

然后启动nginx,仍可以通过命令查看是否已经加入成功

1

/usr/local/nginx/sbin/nginx -V 

server {
        listen       443 ssl;
        server_name  h4u34i.com www.hu43di.com;
        ssl_certificate /usr/local/nginx/conf/cert-15404581652133ndi.com.crt;
        ssl_certificate_key /usr/local/nginx/conf/cert-154045813andi.com.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

         location /pin4ai/ {
                proxy_redirect   off; #注意
                proxy_set_header X-Forwarded-Proto $scheme;#注意
                proxy_pass  http://tomcat8080_cluster_product;
                proxy_set_header Host $http_host;
                proxy_set_header User-Agent $http_user_agent;
                proxy_set_header X-Real-IP  $remote_addr;
                client_max_body_size    600m;
        }
        location / {
            root   html;
            index  index.html index.htm;
        }
    }

 

Tomcat 的 server.xml 的 Host 中配置 Valve:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
    <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
</Host>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值