Nginx&Java笔记-Webservice使用HTTPS协议及Spring Boot配置tomcat

这里最后的效果如下:

Nginx&Java笔记-Webservice使用HTTPS协议及Spring Boot配置tomcat_第1张图片

并且此处soap:address已经换成了https。

 

这里使用Nginx相关配置:

server {
        listen 443 ssl;
        server_name webservice.it1995.cn;
        ssl_certificate /root/web/SSL/webservice.it1995.cn.pem;
        ssl_certificate_key /root/web/SSL/webservice.it1995.cn.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        location / {

                proxy_set_header Host $host:$server_port;
                proxy_set_header X-Forwarded-Proto  $scheme;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8087/;
        }
}

这里是添加这几个头:

Nginx&Java笔记-Webservice使用HTTPS协议及Spring Boot配置tomcat_第2张图片

在spring boot嵌入式tomcat中配置这里我使用的spring boot 2.x

@Configuration
public class TomcatConfig {

    @Bean
    public TomcatServletWebServerFactory servletContainer() {

        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
        RemoteIpValve value = new RemoteIpValve();
        value.setRemoteIpHeader("X-Forwarded-For");
        value.setProtocolHeader("X-Forwarded-Proto");
        value.setProtocolHeaderHttpsValue("https");
        tomcat.addEngineValves(value);
        return tomcat;
    }
}

即可!!!!

 

客户端发送:

服务端接收:

Nginx&Java笔记-Webservice使用HTTPS协议及Spring Boot配置tomcat_第3张图片

你可能感兴趣的:(webservice,Web相关技术,Java,nginx,tomcat,java,spring,boot,webservice)