HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   General (http://www.howtoforge.com/forums/forumdisplay.php?f=25)
-   -   nginx and Rails - delivers random page (http://www.howtoforge.com/forums/showthread.php?t=59119)

theWeird 16th October 2012 12:40

nginx and Rails - delivers random page
 
Hey there.

I already posted this problem in the german forum, but it seems that nobody can help me there.

I've got a funny problem.
One of the servers in my multiserver-setup is installed with nginx and shall deliver Rails-Apps using thin.
At the moment there are only 2 applications on different domains on this system.

The interesting point is, that both apps are delivered, on both domains!
It seems to be random which app is delivered for every single request.
I really get stuck with this problem.
Hoping that anyone in this forum can help me with this problem I am posting all relevant configfiles.

/etc/nginx/proxy.include (included by both hosts)
Code:

    proxy_set_header  Host $http_host;                                                             
    proxy_set_header  X-Real-IP $remote_addr;                                                     
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  X-Forwarded-Proto $scheme;

    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;

/etc/nginx/sites-availible/site1.com.vhost
Code:

server {
        listen *:80;


        server_name site1.com;


        index index.html index.htm index.php index.cgi index.pl index.xhtml;



        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 404 /error/404.html;
        error_page 405 /error/405.html;
        error_page 500 /error/500.html;
        error_page 502 /error/502.html;
        error_page 503 /error/503.html;
        recursive_error_pages on;
        location = /error/400.html {
            internal;
        }
        location = /error/401.html {
            internal;
        }
        location = /error/403.html {
            internal;
        }
        location = /error/404.html {
            internal;
        }
        location = /error/405.html {
            internal;
        }
        location = /error/500.html {
            internal;
        }
        location = /error/502.html {
            internal;
      }

        error_log /var/log/ispconfig/httpd/site1.com/error.log;
        access_log /var/log/ispconfig/httpd/site1.com/access.log combined;

        ## Disable .htaccess and other hidden files
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location /stats {
            index index.html index.php;
            auth_basic "Members Only";
            auth_basic_user_file /var/www/clients/client1/web57/.htpasswd_stats;
        }

        location ^~ /awstats-icon {
            alias /usr/share/awstats/icon;
        }

        location ~ \.php$ {
            deny all;
        }


        include /etc/nginx/proxy.include;
        root /var/www/clients/client1/web57/web/public;
        proxy_redirect off;
        location / {
        try_files $uri/index.html $uri.html $uri @cluster;
        }
            location @cluster {
                proxy_pass http://thin_cluster;
            }
        }
        upstream thin_cluster {
            server unix:/var/www/clients/client1/web57/web/tmp/sockets/site1.com.0.sock;
            server unix:/var/www/clients/client1/web57/web/tmp/sockets/site1.com.1.sock;
            server unix:/var/www/clients/client1/web57/web/tmp/sockets/site1.com.2.sock;
            server unix:/var/www/clients/client1/web57/web/tmp/sockets/site1.com.3.sock;

}

/etc/nginx/sites-availible/site2.com.vhost
Code:

server {
        listen *:80;


        server_name site2.com ;


        index index.html index.htm index.php index.cgi index.pl index.xhtml;



        error_log /var/log/ispconfig/httpd/site2.com/error.log;
        access_log /var/log/ispconfig/httpd/site2.com/access.log combined;

        ## Disable .htaccess and other hidden files
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location /stats {
            index index.html index.php;
            auth_basic "Members Only";
            auth_basic_user_file /var/www/clients/client1/web64/.htpasswd_stats;
        }

        location ^~ /awstats-icon {
            alias /usr/share/awstats/icon;
        }

        location ~ \.php$ {
            deny all;
        }

        include /etc/nginx/proxy.include;
        root /var/www/clients/client1/web64/web/public;
        proxy_redirect off;
        location / {
        try_files $uri/index.html $uri.html $uri @cluster;
        }
            location @cluster {
                proxy_pass http://thin_cluster;
                auth_basic "Developers Only";
                auth_basic_user_file /var/www/clients/client1/web64/web/.htpasswd;
            }
        }
        upstream thin_cluster {
            server unix:/var/www/clients/client1/web64/web/tmp/sockets/site2.com.0.sock;
            server unix:/var/www/clients/client1/web64/web/tmp/sockets/site2.com.1.sock;

}

/etc/thin/site1.com.yml
Code:

pid: tmp/pids/site1.com.pid
group: client1
wait: 30
timeout: 30
log: log/site1.com.log
max_conns: 1024
require: []

environment: production
max_persistent_conns: 512
servers: 4
daemonize: true
user: web57
#socket: /tmp/site1.com.sock
socket: /var/www/clients/client1/web57/web/tmp/sockets/site1.com.sock
chdir: /var/www/clients/client1/web57/web

/etc/thin/site2.com.yml
Code:

pid: tmp/pids/site2.com.pid
group: client1
wait: 30
timeout: 30
log: log/site2.com.log
max_conns: 1024
require: []

environment: development
max_persistent_conns: 512
servers: 2
daemonize: true
user: web64
socket: /var/www/clients/client1/web64/web/tmp/sockets/site2.com.sock
chdir: /var/www/clients/client1/web64/web


theWeird 16th November 2012 13:22

Nobody has an Idea on this problem?
I'm still fighting with this.

falko 17th November 2012 08:30

Seems as if the hostname isn't passed correctly to the backend.

Have you tried it without the "proxy_set_header Host $http_host;" line?

theWeird 17th November 2012 17:59

I commented out the line from proxy.include, but it didn't change anything.
The error still occours.


All times are GMT +2. The time now is 03:05.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.