System Environment: centos
Production Environment: wdlinux
Web engine: nginx + Apache
1. Create a VM in Tomcat
Modify Tomcat \ conf \ Server. xml and add the
<Host name="www.abc.com" appBase="/www/webapps" unpackWARS="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context docBase="/www/webapps/abc" path=""reloadable="true" sessionCookiePath="/" /></Host>
2. Enable reverse proxy in nginx
2. 1. Open the wdlinux/nginx-xxx/CONF/nginx. conf file and add include vhost/*. conf to the last line in the HTTP curly brackets.
2. Create proxy. conf in the nginx-xxx/conf folder and add the following content to the file:
1 proxy_connect_timeout 30s; 2 proxy_send_timeout 90; 3 proxy_read_timeout 90; 4 proxy_buffer_size 32k; 5 proxy_buffers 4 32k; 6 proxy_busy_buffers_size 64k; 7 #proxy_redirect off; 8 proxy_hide_header Vary; 9 proxy_set_header Accept-Encoding ‘‘;10 proxy_set_header Host $host;11 proxy_set_header Referer $http_referer;12 proxy_set_header Cookie $http_cookie;13 proxy_set_header X-Real-IP $remote_addr;14 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
2. 3. Create abc_com.conf in the nginx-xxx/CONF/vhost folder and add the following content to the file:
1 server { 2 listen 80; 3 server_name www.abc.com; 4 root /www/webapps/abc; 5 index index.html index.htm; 6 7 location / { 8 proxy_pass http://localhost:81; 9 proxy_cookie_path /abc/ /;10 include proxy.conf;11 }12 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {13 expires 30d;14 }15 16 location ~ .*\.(js|css)?$ {17 expires 12h;18 }19 }
After the configuration is complete, restart the service to access the ABC project through www.abc.com.
PS: The nginx service must be restarted using the command line method, that is, nginx-xxx/sbin/nginx-s reload.