nginx virtual hosts + mongrel cluster +strange problem
Luc Bernard
lists at ruby-forum.com
Sat Nov 22 01:04:48 MSK 2008
hi all!
I have a dedicated host for my web application
I want to run 2 rails applications with the following adress
http://www.8ansapres.fr and
http://blog.8ansapres.fr
on my server applications have the following path
/home/alpaga/8ansapres.fr/current/
/home/alpaga/blog.8ansapres.fr/
my nginx.conf look like this
user alpaga;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 8192;
use epoll; # linux only!
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"' ;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log notice;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript
text/xml application/xml application/xml+rss
text/javascript;
include /etc/nginx/sites-enabled/*;
}
my first virtual host:
# Load balance to mongrels
upstream mongrel_cluster {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}
# Begin virtual host configuration
server {
# Familiar HTTP settings
listen 80;
server_name www.8ansapres.fr;
root /home/alpaga/8ansapres.fr/current/public;
access_log /var/log/nginx/8ansapres.fr.access.log;
error_page 500 502 503 504 /500.html;
client_max_body_size 50M;
# First rewrite rule for handling maintenance page
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
index index.html index.htm;
# Forward information about the client and host
# Otherwise our Rails app wouldn't have access to it
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_max_temp_file_size 0;
# Directly serve static content
location ~ ^/(images|javascripts|stylesheets)/ {
expires 10y;
}
if (-f $request_filename) {
break;
}
# Directly serve cached pages
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
# Otherwise let Mongrel handle the request
if (!-f $request_filename) {
proxy_pass http://mongrel_cluster;
break;
}
}
}
my second virtual host:
# Load balance to mongrels
upstream mongrel_cluster_two {
server 0.0.0.0:8000;
server 0.0.0.0:8001;
server 0.0.0.0:8002;
}
# Begin virtual host configuration
server {
# Familiar HTTP settings
listen 80;
server_name blog.8ansapres.fr;
root /home/alpaga/blog.8ansapres.fr/public;
access_log /var/log/nginx/blog.8ansapres.fr.access.log;
error_page 500 502 503 504 /500.html;
client_max_body_size 50M;
# First rewrite rule for handling maintenance page
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
index index.html index.htm;
# Forward information about the client and host
# Otherwise our Rails app wouldn't have access to it
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_max_temp_file_size 0;
# Directly serve static content
location ~ ^/(images|javascripts|stylesheets)/ {
expires 10y;
}
if (-f $request_filename) {
break;
}
# Directly serve cached pages
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
# Otherwise let Mongrel handle the request
if (!-f $request_filename) {
proxy_pass http://mongrel_cluster_two;
break;
}
}
}
my mongrel_cluster files
application 1
port: "8000"
pid_file: tmp/pids/mongrel.pid
servers: 3
cwd: /home/alpaga/8ansapres.fr/current/
log_file: log/mongrel.log
environment: production
address: 127.0.0.1
servers: 3
docroot: public
application 2
port: "8003"
pid_file: tmp/pids/mongrel.pid
servers: 3
cwd: /home/alpaga/blog.8ansapres.fr/
log_file: log/mongrel.log
environment: production
address: 0.0.0.0
servers: 3
docroot: public
the first application (8ansapres.fr) run very well but i can't access
the second one.
However, I can access the second application with
http://www.8ansapres.fr:8003/
I did many tests and it's seems I cant' access to
http://blog.8ansapres.fr/
I really don't know were I'am wrong
Do I have to add the subdomain with the registar or something like this
?
thank you very much for your help
the error.log is blank and in blog.8ansapres.fr.access.log i have :
80.96.123.27 - - [21/Nov/2008:22:55:06 +0100] "GET
/w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1" 400 173 "-" "-"
80.96.121.241 - - [21/Nov/2008:22:56:09 +0100] "GET
/w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1" 400 173 "-" "-"
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list