Trouble Understanding IP:PORT / Servername
August 27, 2012 08:23PM
New to nginx. Thought I understood the server config, but I don't think I do, was hoping someone could clarify for me in baby speak :)

How I thought the following code worked is as follows:
- if theres a connection on port 80 and the url is www.example.com, page loads from /usr/local/www/page1
- if theres a connection on port 443 and the url is secure.example.com, page loads from /usr/local/www/page2

if however I type https://www.example.com (note the https) I don't get a page not found error, or some other error. I'm actually redirected to https://secure.example.com

Because there is no server named www.example.com for port 443 I'm confused...?

What am I doing wrong...

would love feedback...

server {
listen 80 default;

server_name www.example.com;
root /usr/local/www/page1;
...
}

server {
listen 443 default;

server_name secure.example.com;
root /usr/local/www/page2;
....
}
Re: Trouble Understanding IP:PORT / Servername
September 22, 2012 03:37PM
Don't know the answer to this but try setting the level of the error log to debug. This helped me many times.
Re: Trouble Understanding IP:PORT / Servername
October 04, 2012 01:51PM
It can't exactly come up with a "page not found" error if there IS a page at www.example.com, nor can it load www.example.com on port 443 since https defaults to 443 and www.example.com is only listening to port 80.

I'd imagine it should come up with an internal server error instead, unless nginx is designed such that, in a situation like this, it will default to the only site on port 443 when you try to use https on a site on port 80 (and you don't specify port 80, e.g. https://www.mysite.com:80).

--
Piki
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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