Welcome! Log In Create A New Profile

Advanced

server_name as sub rather than sub.domain.tld

Posted by hristoast 
server_name as sub rather than sub.domain.tld
July 13, 2011 06:45PM
Greetings,

Nginx version: nginx 0.7.65-1ubuntu2.1

In our office all of our computers are part of our active directory domain, I'll call it office.net.

I use Nginx as a reverse proxy for our Subversion repositories and have it working fine using URLs like "http://project-server.office.net/Project1/", but I can't seem to get it to work using a URL like "http://project-server/Project1/".

The error logs always show something like:

2011/07/13 16:57:18 [error] 7500#0: *1 "/usr/local/nginx/html/Project1/index.html" is not found (2: No such file or directory), client: 172.16.3.56, server: project-server, request: "GET /Project1/ HTTP/1.1", host: "project-server"

This indicates to me that "proxy_pass" is not picking up "project-server" without the office.net in there. Is there a way to achieve this somehow? If I hit "http://project-server:8080/Project1/" I see the repo via Apache, it is indeed recognizing our local domain.

I have tried simply setting the server_name to project-server, I have tried using proxy_redirect to force a redirect (although I may have been doing that wrong), and I explored somehow using rewrite but I don't think that would be appropriate for this situation.

My concerned server { } block is as follows:

server {
listen 80;
server_name project-server.office.net;

location /Project1/ {
proxy_pass http://127.0.0.1:8080;
include proxy.conf;
set $dest $http_destination;
if ($http_destination ~ "^https://(.+)") {
set $dest http://$1;
}
proxy_set_header Destination $dest;
}
}

And my proxy.conf:

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;



Is it possible for Nginx to recognize our local domain like Apache seems to do?

Thanks for reading
-Hristos
Re: server_name as sub rather than sub.domain.tld
July 19, 2011 12:50PM
Just a heads up, the solution for this was incredibly simple. So simple that I overlooked it time and time again.

Once I added "root /path/to/a/docroot/;" to the Vhost everything worked as expected!

Classic pebcak :-)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 250
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready