configuration problem with subdomain and proxy_pass

nicksoft nginx-forum at nginx.us
Wed Nov 23 11:22:24 UTC 2011


Hi,

I have a problem with configuration subdomains for nginx. I want to
configure domains:

mydomain.com (port 80) --> http://localhost:8080/
www.mydomain.com (port 80) --> http://localhost:8080/
subdomain.mydomain.com (port 80) --> http://localhost:8080/subdomain


Tomcat listening at 8080 port on localhost. I have application
'subdomain' in tomcat webapps folder.



This is my configuration file:
------------------------------------------------------
server
{
       listen       80;
       server_name  mydomain.com;

       # Main location
       location /
       {
           proxy_pass         http://127.0.0.1:8080/;
           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       52m;
           client_body_buffer_size    128k;

           proxy_connect_timeout      3600;
           proxy_send_timeout         3600;
           proxy_read_timeout         90;

           proxy_buffer_size          4k;
           proxy_buffers              4 32k;
           proxy_busy_buffers_size    64k;
           proxy_temp_file_write_size 64k;
           proxy_cache_valid 5m;
       }
}

server
{
       listen       80;
       server_name  www.mydomain.com;

       # Main location
       location /
       {
           proxy_pass         http://127.0.0.1:8080/;
           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       52m;
           client_body_buffer_size    128k;

           proxy_connect_timeout      3600;
           proxy_send_timeout         3600;
           proxy_read_timeout         90;

           proxy_buffer_size          4k;
           proxy_buffers              4 32k;
           proxy_busy_buffers_size    64k;
           proxy_temp_file_write_size 64k;
           proxy_cache_valid 5m;
       }
}

server
{
       listen       80;
       server_name subdomain.mydomain.com;

       # Main location
       location /
       {
           proxy_pass         http://127.0.0.1:8080/subdomain/;
           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       52m;
           client_body_buffer_size    128k;

           proxy_connect_timeout      3600;
           proxy_send_timeout         3600;
           proxy_read_timeout         90;

           proxy_buffer_size          4k;
           proxy_buffers              4 32k;
           proxy_busy_buffers_size    64k;
           proxy_temp_file_write_size 64k;
           proxy_cache_valid 5m;
       }
}
------------------------------------------------------


For this configuration http:/www.mydomain.com  and http:/mydomain.com
working very well, but subdomain.mydomain.com doesn't work (there is no
response from server).

Oh, and http://mydomain.com/subdomain in browser works well too.


I will be grateful for your help.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,218793,218793#msg-218793



More information about the nginx mailing list