SSL (HTTPS) implementation of Nginx reverse proxy tomcat

Source: Internet
Author: User
Tags documentation server port tomcat nginx reverse proxy
Tomcat's Server.xml
<?xml vesion= ' 1.0 ' encoding= ' utf-8 '?> <server port= "8005" shutdown= "shutdown" > <listener classname= " Org.apache.catalina.startup.VersionLoggerListener "/> <!--Security Listener. Documentation at/docs/config/listeners.html <listener classname= "Org.apache.catalina.security.SecurityListener "/>-<!--APR Library loader. Documentation At/docs/apr.html--<listener classname= "Org.apache.catalina.core.AprLifecycleListener" Sslengine= "on"/> <!--Prevent memory leaks due to use of particular Java/javax apis--> <listener Classnam E= "Org.apache.catalina.core.JreMemoryLeakPreventionListener"/> <listener classname= " Org.apache.catalina.mbeans.GlobalResourcesLifecycleListener "/> <listener classname=" Org.apache.catalina.core.ThreadLocalLeakPreventionListener "/> <GlobalNamingResources> <resource name=
       "Userdatabase" auth= "Container" type= "Org.apache.catalina.UserDatabase"       description= "User database that can be updated and saved" factory= "Org.apache.catalina.users.MemoryUs Erdatabasefactory "pathname=" Conf/tomcat-users.xml "/> </GlobalNamingResources> <service na
               Me= "Catalina" > <connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "443" proxyport= "443"/> <connector port= "8009" protocol= "ajp/1.3" Redirectport = "8443"/> <engine name= "Catalina" defaulthost= "localhost" > <realm classname= "Org.apache.catalina . Realm. Lockoutrealm "> <realm classname=" Org.apache.catalina.realm.UserDatabaseRealm "Resourcename=" Userdatabase "/> </Realm>  
below is the *.conf file inside the nginx conf.d file 

server {# Listen 80;
    SSL on;
    Listen 443 SSL;
    server_name localhost;
    SSL_CERTIFICATE/ETC/NGINX/CONF.D/IDEALN_CA/FULLCHAIN.PEM;
    SSL_CERTIFICATE_KEY/ETC/NGINX/CONF.D/IDEALN_CA/PRIVKEY.PEM;


    SSL_TRUSTED_CERTIFICATE/ETC/NGINX/CONF.D/IDEALN_CA/CHAIN.PEM;
    #charset Koi8-r;

    #access_log/var/log/nginx/log/host.access.log Main;

    Error_page 404/404.html;
    Error_page 502 503 504/50x.html;
    Location =/50x.html {root/usr/share/nginx/html; } location ~* \.
        (jpg|jpeg|png|gif|ico|obj|mtl|mp4|txt|doc|excel|pdf|bmp|rar|zip|gz|tar|tgz|svg) $ {access_log off;
        Add_header Cache-control "public";
        Proxy_cache Cache_one;
        Proxy_cache_valid 304 302 5d;
        Proxy_cache_valid any 5d;
        Proxy_cache_key ' $host: $server _port$request_uri '; Add_header X-cache ' $upstream_cache_status from $host ';
        Root/opt/tomcat/webapps/root;
     Expires 15d; } location ~* \.
        (HTML|JS|CSS) $ {Proxy_cache cache_one;
        Proxy_cache_valid 304 302 5d;
        Proxy_cache_valid any 5d;
        Proxy_cache_key ' $host: $server _port$request_uri ';
        Add_header X-cache ' $upstream _cache_status from $host ';
        Root/opt/tomcat/webapps/root;
     Expires 5d;
        } location ~. *$ {Proxy_pass http://127.0.0.1:8080;
        Proxy_set_header Host $http _host;
        Proxy_redirect off;
        Proxy_set_header X-real-ip $remote _addr;
        Proxy_set_header X-scheme $scheme;
        Proxy_set_header X-ssl-protocol $ssl _protocol;
        Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
        Proxy_set_header X-https-protocol $ssl _protocol;
        #对应tomcat的server. XML settings Proxy_set_header X-forwarded-proto $scheme;
     expires-1; }

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.