Created
October 20, 2009 12:05
-
-
Save hipertracker/214210 to your computer and use it in GitHub Desktop.
Revisions
-
hipertracker revised this gist
Oct 22, 2009 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -40,9 +40,9 @@ because the same rule for APACHE WORKS FINE. SOLUTION To duplicate Apache behavior, Nginx need few additional HTTP headers: server { listen myhost:80; server_name myhost; location / { -
hipertracker revised this gist
Oct 22, 2009 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ 127.0.0.1 myhost jboss_server NGINX: server { listen myhost:80; server_name myhost; -
hipertracker revised this gist
Oct 22, 2009 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -53,5 +53,4 @@ erver { } } (It was also added to http://wiki.nginx.org/NginxLikeApache) -
hipertracker revised this gist
Oct 22, 2009 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,26 @@ because the same rule for APACHE WORKS FINE. <VirtualHost *:80> ServerName myhost DocumentRoot /path/to/rails1/public ProxyPass / http://rails1:8080/ ProxyPassReverse / http://rails1:8080/ </VirtualHost> SOLUTION After several hours of testing different Nginx settings, I found the final solution. To duplicate Apache behavior, Nginx need few additional HTTP headers: erver { listen myhost:80; server_name myhost; location / { root /path/to/rails1/public; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://rails1:8080; } } It was also added to http://wiki.nginx.org/NginxLikeApache It wasadded also to http://wiki.nginx.org/NginxLikeApache -
hipertracker revised this gist
Oct 21, 2009 . 1 changed file with 15 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,15 @@ /etc/hosts: 127.0.0.1 myhost jboss_server NGINX: server { listen myhost:80; server_name myhost; location / { 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; proxy_pass http://rails1:8080; } } @@ -33,12 +21,18 @@ $ $TORQUEBOX_HOME/jboss/run.sh -c web -b jboss_server $ elinks http://jboss_server:8080 returns error404, but it is fine because I removed root.war file $ elinks http://rails1:8080 works fine, it opens Ruby on Rails application $ elinks http://myhost returns error404. It looks like Nginx has some issues with reverse proxy because the same rule for APACHE WORKS FINE. <VirtualHost *:80> ServerName myhost ProxyPass / http://rails1:8080/ ProxyPassReverse / http://rails1:8080/ </VirtualHost> -
hipertracker revised this gist
Oct 20, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ server { TEST Starting JBoss: $ $TORQUEBOX_HOME/jboss/run.sh -c web -b jboss_server $ elinks http://jboss_server:8080 returns error404, but it is fine because I removed root.war file -
hipertracker revised this gist
Oct 20, 2009 . 1 changed file with 0 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -42,13 +42,3 @@ or http://jboss_server:8080.. (JBoss distinguish between http://homepage:8080 and http://127.0.0.2:8080 even if it is the same IP). -
hipertracker revised this gist
Oct 20, 2009 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -40,3 +40,15 @@ $ elinks http://mydomain returns error404. It looks like it opens http://127.0.0.2:8080 or http://jboss_server:8080.. (JBoss distinguish between http://homepage:8080 and http://127.0.0.2:8080 even if it is the same IP). SOLUTION! Change nginx settings. Replace proxy_set_header Host $http_host; with proxy_set_header Host homepage; -
hipertracker created this gist
Oct 20, 2009 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ /etc/hosts: 127.0.0.2 homepage jboss_server 127.0.0.4 mydomain NGINX: /etc/nginx/sites-enabled/mydomain.conf: server { listen mydomain:80; server_name mydomain; location / { if (-f $request_filename) { access_log off; expires 30d; break; } proxy_redirect off; 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; proxy_set_header "ENABLE_X_ACCEL_REDIRECT" "true"; proxy_pass http://homepage:8080; } } TEST Starting JBoss: $ TORQUEBOX_HOME/jboss/run.sh -c web -b jboss_server $ elinks http://jboss_server:8080 returns error404, but it is fine because I removed root.war file $ elinks http://homepage:8080 works fine, it opens Ruby on Rails application $ elinks http://mydomain returns error404. It looks like it opens http://127.0.0.2:8080 or http://jboss_server:8080.. (JBoss distinguish between http://homepage:8080 and http://127.0.0.2:8080 even if it is the same IP).