Nginx+Tomcat implements reverse proxy

Domain name access through nginx to tomcat without project name configuration method:

1. Configure tomcat to modify server.xml, add context access path as "/" at the end of Host, as follows:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
        <Context path="/" docBase="/usr/local/tomcat/webapps/sms/" debug = "0" reloadable="true" crossContext="true" />
</Host>

 

2. Modify nginx as follows:

server {
    listen       80;
    server_name sms.baidu.com; --Set the domain name
 
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
            proxy_pass  http://172.16.3.187:30001;
            #proxy_redirect  http://172.16.3.187:30001/ams/ /;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    #error_page  404              /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325013302&siteId=291194637