Want more timely Centmin Mod News Updates?
Become a Member

Nginx default nginx vHost

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Danail Vanchev, Oct 9, 2014.

Tags:
  1. Danail Vanchev

    Danail Vanchev Goshev

    8
    4
    3
    Jul 23, 2014
    Ratings:
    +4
    Local Time:
    8:56 PM
    Multiple releases
    10.3
    Hello,


    I have tested the nginx installation with centmin on a few servers and it seems it does create virtual.conf which should act as default virtual host in case a domain is pointed to the server IP but has no nginx config file. However this does not work. As I have to use listen IP:80 for each domain because I have multiple IPs on each server this does not even work if I modify the virtual.conf with the IP I want to test.

    Is there a way to add wildcard nginx vHost which will handle all the requests to domains which are not present on the server and redirect those to certain page?

    Additionally is there an option to add nginx referal module as this helps protect from spam referal links and lots of other bad traffic google hates.

    Thank you for the help guys in advance.
     
  2. eva2000

    eva2000 Administrator Staff Member

    53,865
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    4:56 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    can you post link to the nginx referral module you're talking about ? or do you mean nginx referer module Module ngx_http_referer_module ?

    FYI, the nginx referer module is a standard core supported module in Nginx which doesn't need adding as it's supported out of the box accordng to list at Modules - Nginx Community

    From Nginx - Centmin Mod - Menu based Nginx installer for CentOS servers you can see an example of how to enable Nginx WebDAV module support and add nginx-dav-ext-module support can be read here if you still curious as to how to extend your own nginx modules.

    As to wildcard, read about default_server parameter for each listen ip:port at How nginx processes a request and Server names

    FYI, in most cases for proper Centmin Mod Nginx operation the server_name in virtual.conf pertaining to default hostname of server should always been default_server for main ip address as alot of Centmin Mod addons like phpmyadmin, linfo and default stats pages for APC Cache, Xcache and Zend Opcache and Memcache rely on serving from default server hostname.domain.com/* which would have public web root at /usr/local/nginx/html.

    Of course you can move those stats pages elsewhere and change default_server if you want. Just know that Centmin Mod updates or fixes or improvements won't know where to do future automatic updates for those features or components if you do move them.
     
    Last edited: Oct 9, 2014
  3. Danail Vanchev

    Danail Vanchev Goshev

    8
    4
    3
    Jul 23, 2014
    Ratings:
    +4
    Local Time:
    8:56 PM
    Multiple releases
    10.3
    Indeed it was core module did not see that apologies.

    However as for the default nginx vHost. Virtual.conf has in it the info to handle all the requests to unexisting content but it does not correctly handle those requests because of some reason. That is why I am asking if there is an option to setup that as catchall virtual host. It will be better as this way it will stop lots of bad traffic if such is sent from another domain pointed by A record only for a domain on our machine.

    Allow me to send you PM with an example that the virtual.conf is not working as it should.
     
  4. rdan

    rdan Well-Known Member

    5,439
    1,399
    113
    May 25, 2014
    Ratings:
    +2,188
    Local Time:
    2:56 AM
    Mainline
    10.2
    Please let me know the solution also for server having multiple IP.
    Thanks!
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,865
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    4:56 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+