nginx的配置,要求根据不同的来路域名,发送到不同的端口去处理

这一台电脑上既有tomcat 也有 apache,他俩是没有办法同时享用80端口的。我现在让tomcat用8088,apache用8080,然后让nginx用80,这样nginx在收到请求后,根据不同的域名转到8088或8080去处理。 如 http://www.abc.com 转到8088,http://bbs.abc.com转到8080,该如何写nginx的配置文件。跪求,在线等。
http {
upstream www
{
server xxx.xxx.xxx.xxx:8088 max_fails=3 fail_timeout=30s;
}
upstream bbs
{
server xxx.xxx.xxx.xxx:8080 max_fails=3 fail_timeout=30s;
} server {
listen 80;
server_name www.abc.com;
location / {
index index.html index.php index.jsp index.htm;
proxy_pass http://www;
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;
#proxy_connect_timeout 90;
#proxy_send_timeout 90;
#proxy_read_timeout 90;
#proxy_buffers 32 4K;
}
log_format '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$server_addr;" "$upstream_addr "'; }
server {
listen 80;
server_name bbs.abc.com ;
location / {
index index.html index.php index.jsp index.htm;
proxy_pass http://bbs;
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;
#proxy_connect_timeout 90;
#proxy_send_timeout 90;
#proxy_read_timeout 90;
#proxy_buffers 32 4K;
}
} }#end of http
上一篇:jQuery.ajax( options ) : 通过 HTTP 请求加载远程数据


下一篇:Promise 用法