yaoweibin / nginx_tcp_proxy_module

add the feature of tcp proxy with nginx, with health check and status monitor
http://yaoweibin.github.com/nginx_tcp_proxy_module
1.65k stars 365 forks source link

Multiple proxies with name based virtual hosts? #55

Open kcowgill opened 12 years ago

kcowgill commented 12 years ago

I'm attempting to get one nginx process to proxy for two separate webapps differentiated by hostname. Here's my nginx.conf:

worker_processes  1;

events {
    worker_connections  1024;
}

tcp {
  upstream app1 {
    server 127.0.0.1:8000;
  }
  upstream app2 {
    server 127.0.0.1:9000;
  }
  server {
    listen 80;
    server_name app1;
    proxy_pass app1;
    access_log /sitelogs/nginx/app1-access.log;
  }
  server {
    listen 80;
    server_name app2;
    proxy_pass app2;
    access_log /sitelogs/nginx/app2-access.log;
  }
}

but it doesn't seem to be working. Any requests to the box at either hostname are all getting proxied to app1.

Is what I'm trying possible, or do I need to find another solution? What am I missing?

Thanks!

yaoweibin commented 12 years ago

yes, use the websocket proxy module, see the readme for dedail.

在 2012 年 10 2 日,1:02 上午,"Kent Cowgill" notifications@github.com编写:

I'm attempting to get one nginx process to proxy for two separate webapps differentiated by hostname. Here's my nginx.conf:

worker_processes 1;

events { worker_connections 1024;} tcp { upstream app1 { server 127.0.0.1:8000; } upstream app2 { server 127.0.0.1:9000; } server { listen 80; server_name app1; proxy_pass app1; access_log /sitelogs/nginx/app1-access.log; } server { listen 80; server_name app2; proxy_pass app2; access_log /sitelogs/nginx/app2-access.log; }}

but it doesn't seem to be working. Any requests to the box at either hostname are all getting proxied to app1.

Is what I'm trying possible, or do I need to find another solution? What am I missing?

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/yaoweibin/nginx_tcp_proxy_module/issues/55.