1. What is Nginx?
nginx [engine x] is an HTTP and reverse proxy server written by Igor Sysoev, and it can also act as a mail proxy server. It has been used for a long time on many high-traffic Russian sites, including Yandex, Mail.Ru, VKontakte, and Rambler. According to Netcraft statistics, in August 2012, 11.48% of the world's busiest websites use Nginx as their server or proxy server (see: http://nginx.org/cn/ or google).
2. Nginx+Tomcat configuration under Windows
Nginx :http://nginx.org/
Tomcat:http://tomcat.apache.org/
My local environment is Windows XP+Nginx 1.0.15+ apache-tomcat-7.0.34
1. Nginx installation: Nginx download and decompress to any directory without spaces and Chinese characters on the machine.
2, conf/nginx.conf configuration file modification
a: Modify Nginx default port:
- server {
- listen 80;
- server_name localhost;
- ......
- }
The listen here is listening, the default port is 80, if necessary, it can be changed to other ports.
b: increase after keepalive_timeout
- upstream location {
- The #weigth parameter represents the weight, the higher the weight, the greater the probability of being assigned
- server 127.0.0.1:8048 weight=3;
- server 127.0.0.1:8049 weight=2;
- ip_hash;
- }
c: modify
- location / {
- root html;
- index index.html index.htm;
- }
for
- location / {
- root html;
- index index.html index.htm;
- proxy_pass http://location;
- 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 90;
- proxy_send_timeout 90;
- proxy_read_timeout 90;
- proxy_buffer_size 4k;
- proxy_buffers 4 32k;
- proxy_busy_buffers_size 64k;
- proxy_temp_file_write_size 64k;
- }
3. Modify the port configuration in Tomcat server.xml so that this machine can run multiple Tomcats. Note that the Tomcat publishing port should be the same as the mapped port in 2.a.
At this point, the configuration is complete, enter http://127.0.0.1:80 (or custom port) to access
Reprinted from: http://guomingjun.iteye.com/blog/1939158