Problem with setting Virtual Hosts

i need help :frowning:

I wrote as the following site.

http://wiki.nginx.org/VirtualHostExample

here is my nginx.conf

user www www;
worker_processes 1;
error_log /data/logs/nginx_error.log crit;
pid /opt/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by
this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;

#charset gb2312;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css
application/xml;
gzip_vary on;
server {
listen 80 default;
server_name _;
access_log logs/default.access.log;

server_name_in_redirect off;

root  /data/www;

}
#limit_zone crawler $binary_remote_addr 10m;
server {

Replace this port with the right one for your requirements

listen 80; #could also be 1.2.3.4:80

Multiple hostnames separated by spaces. Replace these as well.

server_name star.domain.com *.domain.com; # Alternately: _

root /data/www/$host/;

error_page 404 errors/404.html;
access_log logs/star.domain.com.access.log;

index index.php index.html index.htm;

serve static files directly

location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}

location ~ .php$ {
fastcgi_intercept_errors on;
# By all means use a different server for the fcgi processes if you
need to
fastcgi_pass 127.0.0.1:9000;
}

location ~ /.ht {
deny all;
}
}

}

when i vist a.domain.com

but the website redirect to the following site.

http://a.domaincom/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/404.html

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

On Wed, Mar 23, 2011 at 01:16:14PM -0400, chatfeed wrote:

Hi there,

I wrote as the following site.

http://wiki.nginx.org/VirtualHostExample

Despite what it shows on that page, it is usually best…

server_name star.domain.com *.domain.com; # Alternately: _

root /data/www/$host/;

error_page 404 errors/404.html;

…if the last argument to error_page starts with “/” or “@”.

So make it “/errors/404.html” and you should see something more
useful. (Or just remove the line entirely, for a slightly different
result.)

when i vist a.domain.com

but the website redirect to the following site.

http://a.domaincom/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/404.html

You ask for http://a.domain.com/; nginx presumably doesn’t see the file
/data/www/a.domain.com/index.php and so generates a http 404 error; your
error_page setting says “do an external redirect to errors/404.html”,
which is returned to your browser.

It then asks for http://a.domain.com/errors/404.html; nginx doesn’t see
the file /data/www/a.domain.com/errors/404.html and generates a http
404 error which becomes an external redirect, so your browser asks for
http://a.domain.com/errors/errors/404.html; and this continues until
your browser decides it has seen too many redirects.

So: delete or change the error_page line to prevent the loop; and add
content to the right directory to avoid the initial 404 error.

Good luck with it,

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs