Created
May 8, 2012 10:10
-
-
Save eagleon/2634028 to your computer and use it in GitHub Desktop.
Nginx和Tomcat配合的最简单例子
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
upstream adz { | |
server 127.0.0.1:8282 weight=3; | |
} | |
server { | |
listen 80; | |
server_name dev.adzoner.com; | |
root /usr/local/tomcat/www/adzoner/adzoner; | |
location / { | |
root /usr/local/tomcat/www/adzoner/adzoner; | |
index index.html index.htm index.jsp; | |
} | |
location ~ ^/WEB-INF/* {#禁止访问被保护的目录 | |
deny all; | |
} | |
location ~ \.do$ { | |
proxy_pass http://adz;#转发给tomcat端口,也可以是任何server。 | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
} | |
location ~ \.jsp$ { | |
proxy_pass http://adz;#myproject可以任意自定义,但是一定要在前面加http:// | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
} | |
location ~ ^/servlets/* { | |
proxy_pass http://adz; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment