nginx+tomcat配置https

xiaoxiao2025-11-07  4

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>
转载请注明原文地址: https://www.6miu.com/read-5039235.html

最新回复(0)