Nginx Reverse Proxy non listening domain catch all -


using nginx reverse proxy have noted if site pointed @ server not exist served existing site on server rather domain cannot found message or similar.

ie config block listening portal.test.org user points there cname nginx system domain header of smartportal.test.org

or point site portal.test2.org

could direct me on following

a. how nginx decides site return when not exist virtual host b. how catch domain not specified , return default page tells users domain not exist on host

hope can have tried googling think knowing correct terms.

many thanks

you should use default_server parameter of listen directive , server_name directive.

your questions

  • how nginx decides site return when not exist virtual host

    listen [default_server]

    if directive has default_server parameter, enclosing server {...} block default server address:port pair. useful name-based virtual hosting wish specify default server block hostnames not match server_name directives. if there no directives default_server parameter, default server first server block in address:port pair appears.


    server_name

    this directive performs 2 actions:

    compares host header of incoming http request against server { ... } blocks in nginx configuration files , selects first 1 matches. how virtual servers defined. server names processed in following order:

    1.- full, static names

    2.- names wildcard @ start of name — *.example.com

    3.- names wildcard @ end of name — www.example.*

    4.- names regular expressions

    if there no match, server { ... } block in configuration file used based on following order:

    1.- server block matching listen directive marked [default|default_server]

    2.- first server block matching listen directive (or implicit listen 80;)

  • how catch domain not specified , return default page tells users domain not exist on host

    server {   listen 1.2.3.4:80 default_server;   server_name _ "";   location / {     alias /var/www/html/domain-does-not-exists.html;     } }  server {   listen 1.2.3.4:80 ;   server_name portal.test.org;   location / {       ... site ...    } } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -