I want to use 2 domains www.domain1.com and www.domain2.com.
When i go to www.domain2.com it goes to domain1.com
I have included my nginx.conf (upstream = mongrel)
I don´t understand what´s wrong…
user and group to run as
user root root;
number of nginx workers
worker_processes 6;
pid of nginx master process
pid /var/run/nginx.pid;
Number of worker connections. 1024 is a good default
events {
worker_connections 1024;
}
start the http module where we config http access.
http {
pull in mime-types. You can break out your config
into as many include’s as you want to make it cleaner
include /etc/nginx/mime.types;
server_names_hash_bucket_size 128;
set a default type for the rare situation that
nothing matches from the mimie-type include
default_type application/octet-stream;
configure log format
log_format main '$remote_addr - $remote_user [$time_local] ’
'“$request” $status $body_bytes_sent “$http_referer”
’
‘“$http_user_agent” “$http_x_forwarded_for”’;
main access log
access_log /var/log/nginx_access.log main;
main error log
error_log /var/log/nginx_error.log debug;
no sendfile on OSX
sendfile on;
These are good default values.
tcp_nopush on;
tcp_nodelay off;
output compression saves bandwidth
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;
this is where you define your mongrel clusters.
you need one of these blocks for each cluster
and each one needs its own name to refer to it later.
upstream domain1 {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
}
upstream domain2 {
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;
server_name www.domain1.com;
access_log /home/public_html/domain1/log/access.log;
error_log /home/public_html/domain1/log/error.log;
root /home/public_html/domain1/public/;
index index.html;
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_redirect false;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html
break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://domain1;
break;
}
}
}
server {
listen 80;
server_name www.domain2.com;
access_log /home/public_html/domain2/log/access.log;
error_log /home/public_html/domain2/log/error.log;
root /home/public_html/domain2/public/;
index index.html;
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_redirect false;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html
break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://domain2;
break;
}
}
}
}