Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx subdomain display 404?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by jellday, Mar 30, 2016.

  1. jellday

    jellday Member

    83
    4
    8
    May 31, 2014
    Ratings:
    +11
    Local Time:
    10:13 AM
    1.4.6
    5.5
    Code:
    server {
            server_name *.mydomainname.info;
            if ( $host ~* (\b(?!www\b)\w+)\.\w+\.\w+ ) {
                   set $subdomain /$1;
             }
            location / {
                    root /home/nginx/domains/mydomainname.info/public$subdomain;
                    index index.html index.php;
             }
            location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.mydomainname.info;
                    proxy_pass      http://127.0.0.1:80;
                    }
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    
      if ($http_user_agent ~* "(YisouSpider|EasouSpider|EtaoSpider)") {
       return 403;
      }
        }
    some subdomain is all right, but some are not.
    It seems to me that if the index file is index.html, then subdomain.mydomain.info is all right
    if the index file is index.php, then shows 404 error. Don't know why

     
  2. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:13 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)

    any clues in your access.log and error.log in vhost listed paths at
    Code (Text):
    access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=60m;
    error_log /home/nginx/domains/domain.com/log/error.log;
    


    Not sure but try moving the root path out of root / to server context ?
    Code (Text):
    root /home/nginx/domains/mydomainname.info/public$subdomain;