Start Nginx First
1. Go to nginx directory:/usr/local/nginx;
Start Nginx:
/usr/local/nginx/nginx
To add sudo before Ubuntu;
Key configuration
Under HTTP configuration block, the general settings are under ZGIP on:
localhost #绿色对应 #ip_hash; Server localhost:8090; Server localhost:8080;}
Server/ { / { proxy_connect_timeout 3; Proxy_send_timeout ; Proxy_read_timeout ; Proxy_pass http://localhost; }}
Test effect
The final test is in effect; under root directory, generally root project, find index.jsp Modify the top-level menu has <div class= "asf-box" > Add suffix h1 in _8080 tag according to port number (related Tomcat configuration port ); Restart Nginx First:
Nginx] Nginx-s Reload
Use smooth restart;
In the early version of Nginx, Nginx reboot requires the KILL command to send a signal to Nginx to implement the Nginx reboot. However, now, Nginx added the-s option to implement Nginx stop, reload function. 1. If it is a smooth restart Nginx, you can use the ./nginx-s Reload command to achieve a smooth restart of nginx. (feasible) 2. If the non-smooth restart, you can stop the Nginx, and then start:./nginx-s Stop &&/nginx When we modify the Nginx configuration, we want to restart Nginx for Nginx to take effect. At this time in order to ensure that nginx in the restart phase can also provide a normal service, generally using a smooth restart (reload) restart Nginx. At this point, Nginx loads the new configuration and then fork out the new worker process. At the same time, the master process sends a signal to the old worker process to tell the old worker process the current situation. After the old worker process is signaled by the master process, if the request is not processed then it exits, and if the request is being processed, the old worker process finishes processing the request and exits. Nginx is this way to reload the new configuration, so that in the process of restarting, can still provide services.
Run two tomcat at the same time [8080, 8090] View: Installation configuration for VMware Linux under Nginx-tomcat configuration (ii)
Nginx installation Configuration start: Installation configuration of VMware Linux under Nginx (i)
Finally through the VMWare Linux server IP access: http://xxx.xxx.xxx.xxx/access to see the effect, if successful, the above root index.jsp H1 modified content (apache/tomcat/version< /c0>), the page refresh will change between 8080 and 8090.
as follows: 8080
2.8090
NGINX.CONF Location Block Configuration
Location/{root HTML; Index index.html index.htm; Proxy_pass http://backend;Proxy_redirect off; Proxy_set_header Host $host; Proxy_set_header X-real-IP $remote _addr; Proxy_set_header X-forwarded-For $proxy _add_x_forwarded_for; Client_max_body_size 10m; Client_body_buffer_size 128k; Proxy_connect_timeout -; Proxy_send_timeout -; Proxy_read_timeout -; Proxy_buffer_size 4k; Proxy_buffers432k; Proxy_busy_buffers_size 64k; Proxy_temp_file_write_size 64k;}
VMware Linux under Nginx installation configuration-nginx.conf configuration [Load two Tomcat] (iii)