Welcome! Log In Create A New Profile

Advanced

Re: Nginx Server : Desired Domain Name on Local Host

Francis Daly
June 16, 2012 09:52AM
On Sat, Jun 16, 2012 at 06:38:53PM +0530, Chetan Patil wrote:

Hi there,

> I am trying to understand how nginx will receive desired domain request and
> how it will display the html pages.

<snip>

> Before moving to a real server I want to understand exactly how nginx gets
> request
> from desired domain name (example.com) and then shows the relevant data.

http://nginx.org/en/docs/http/request_processing.html

In short: the connection comes in on an ip:port, and includes an indication
of the server name requested (usually in the http request Host: header).

For every server{} defined, nginx checks for the ones with a "listen"
directive that is the best-match for the ip:port; for each of those
servers, nginx finds the one with the best-match "server_name" directive,
or else uses the default one.

After that, the server-level config or the best-match location{} is used
to decide how to respond to the request.

But all of that can only happen after the request gets to nginx.

> In browser when I type : test:80 , it shows webpage not available, instead
> of showing nginx default test page.

Browsers tend to hide the actual error message behind a "friendly" one.

What does

curl -i http://test:80/

show?

I suspect it will be something along the lines of

Couldn't resolve host 'test'

In that case, your browser never actually sent the request to nginx,
so nginx could do nothing about it.

One way to direct the request you want at the localhost web server is

curl -i -H 'Host: test' http://localhost/

The best way is to set up name resolution such that your browser knows
that the name "test" corresponds to your nginx server. In the common case,
adding a line

127.0.0.1 test

to /etc/hosts will make it all Just Work for all browsers on the system.

(If you're not in the common case, then other things may be needed. But
that's all outside of nginx.)

All the best,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx Server : Desired Domain Name on Local Host

Chetan Patil June 16, 2012 09:10AM

Re: Nginx Server : Desired Domain Name on Local Host

Francis Daly June 16, 2012 09:52AM

Re: Nginx Server : Desired Domain Name on Local Host

Chetan Patil June 16, 2012 11:26AM

Re: Nginx Server : Desired Domain Name on Local Host

Francis Daly June 16, 2012 01:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 288
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