Join the community today
Become a Member

PHP-FPM Subdomain not showing php image properly

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by jellday, Jul 8, 2017.

Tags:
  1. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    • CentOS Version: CentOS 6 32bit
    • Centmin Mod Version Installed: 123.08stable
    • Nginx Version Installed: 1.13.1
    • PHP Version Installed: 5.5.38
    • MariaDB MySQL Version Installed:10.0.31
    • When was last time updated Centmin Mod code base ? : Never
    • Persistent Config: Do you have any persistent config file options set in /etc/centminmod/custom_config.inc ? No
    I set abc.mydomain.com pointed to mydomain.com/abc, and now the webpage showing a captcha image is not shown at all under abc.mydomain.com/somepage.html, but if you visit from mydomain.com/abc/somepage.html, it is shown properly.

    Another problem is, the search section under abc.mydomain.com/somepage.html will go blank when you try to submit a search form, and it is working via mydomain.com/abc/somepage.html. As I remembered, no problem showed at all using the old centminmod until a recently migration. Help, please.
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,561
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,266
    Local Time:
    3:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags).
     
  3. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    I replaced the real domain with newdomain.com for security reasons:
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name newdomain.com;
                return 301 $scheme://www.newdomain.com$request_uri;
           }
    
    server {
      server_name www.newdomain.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/newdomain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/newdomain.com/log/error.log;
    
      root /home/nginx/domains/newdomain.com/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      } 
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Enable for vBulletin usage WITHOUT vbSEO installed
      # More example Nginx vhost configurations at
      # http://centminmod.com/nginx_configure.html
      #try_files        $uri $uri/ /index.php;
        rewrite ^/(.+)/(\d+)\/?$ /e/action/ListInfo.php?classid=$2&ph=1&city=$1;
        rewrite ^/(.+)/(\d+)-p(\d+)\/?$ /e/action/ListInfo.php?page=$3&classid=$2&ph=1&city=$1;
        rewrite ^/contact/?$ /e/tool/feedback/?bid=1;
        rewrite ^/guestbook/?$ /e/tool/gbook/?bid=1;
        rewrite ^/space-(\d+).html$ /e/space/index.php?userid=$1;
        rewrite ^/feed-(\d+)\.xml$ /e/web/?type=rss2&classid=$1;
        rewrite ^/post-(\d+)\.shtml$ /e/DoInfo/AddInfo.php?classid=$1;
        rewrite ^/branch_(\d+)_(\d+)/?$ /e/DoInfo/AddBranch.php?classid=$1&id=$2;
        rewrite ^/reply/(\d+)-(\d+)\.html$ /e/pl/?id=$1&classid=$2 last;
        rewrite ^/comment-(\d+)-(\d+)\.html$ /e/pl/?id=$1&classid=$2 last;
        rewrite ^/tag-(.+)-(\d+)\.html$ /e/tags/?tagname=$1&classid=$2;
        rewrite ^/tag-(.+)-(\d+)-(\d+)\.html$ /e/tags/index.php?tagname=$1&classid=$2&page=$3;
        rewrite ^/house/rent/(.*) http://rent.newdomain.com/$1 permanent;
    #    rewrite ^/house/tolet/(.*) http://let.newdomain.com/$1 permanent;
        rewrite ^/vehicle/car/(.*) http://car.newdomain.com/$1 permanent;
        rewrite ^/e/DownSys/report?classid=(\d+)&id=(\d+) /e/public/report/?classid=$1&id=$2 permanent;
    
      }
    
      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/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    server {
            server_name rent.newdomain.com;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/nginx/domains/newdomain.com/public/house/rent/;
      # limit_conn limit_per_ip 16;
      # ssi  on;
      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;
      }
              location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.newdomain.com;
                    proxy_pass      http://127.0.0.1:80;
                    }
    }
    server {
            server_name let.newdomain.com;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/nginx/domains/newdomain.com/public/house/tolet/;
      # limit_conn limit_per_ip 16;
      # ssi  on;
      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;
      }
              location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.newdomain.com;
                    proxy_pass      http://127.0.0.1:80;
                    }
    }
    
    server {
            server_name auto.newdomain.com;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/nginx/domains/newdomain.com/public/vehicle/;
      # limit_conn limit_per_ip 16;
      # ssi  on;
      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;
      }
              location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.newdomain.com;
                    proxy_pass      http://127.0.0.1:80;
                    }
    }
    server {
            server_name car.newdomain.com;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/nginx/domains/newdomain.com/public/vehicle/car/;
      # limit_conn limit_per_ip 16;
      # ssi  on;
      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;
      }
              location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.newdomain.com;
                    proxy_pass      http://127.0.0.1:80;
                    }
    }
    server {
            server_name yp.newdomain.com;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/nginx/domains/newdomain.com/public/dianping/;
      # limit_conn limit_per_ip 16;
      # ssi  on;
      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;
      }
              location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.newdomain.com;
                    proxy_pass      http://127.0.0.1:80;
                    }
    }
    
    server {
        server_name *.newdomain.com;
            if ( $host ~* (\b(?!www\b)\w+)\.\w+\.\w+ ) {
                   set $subdomain /$1;
             }
             root /home/nginx/domains/newdomain.com/public$subdomain;
             index index.html index.php;
            location ~ ^/(ads|d|e|skin)/
                    {
                    proxy_redirect        off;
                    proxy_set_header    Host   www.newdomain.com;
                    proxy_pass      http://127.0.0.1:80;
                    }
      # limit_conn limit_per_ip 16;
      # ssi  on;
      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;
      }
    }
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,561
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,266
    Local Time:
    3:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    first off, setup separate access_log and error_log paths for each subdomain's server {} context so you can troubleshoot the logs i.e. main vhost has
    Code (Text):
      access_log /home/nginx/domains/newdomain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/newdomain.com/log/error.log;
    

    so maybe for rent.newdomain.com have within it's server {} context
    Code (Text):
      access_log /home/nginx/domains/newdomain.com/log/access-rent.newdomain.com.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/newdomain.com/log/error-rent.newdomain.com.log;
    

    and so on and so on

    restart nginx after and view the logs for clues
     
  5. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    Well, I did, and checked, but nothing was logged.
    Do you think it is some kind of cross domain thing? I can't find any errors related though.
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,561
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,266
    Local Time:
    3:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    Try enabling nginx debug mode for your ISP ip only and see if logs reveal more.

    To enable, add to persistent config file /etc/centminmod/custom_config.inc the variable NGINX_DEBUG=y and recompile Nginx via centmin.sh menu option 4 and then setting error_log in nginx vhosts to debug as outlined at nginx.org/en/docs/debugging_log.html & wiki.nginx.org/Debugging.

    You do not want to leave Nginx debug mode running forever, so after debugging, set NGINX_DEBUG=n or remove the variable from the persistent config file /etc/centminmod/custom_config.inc and recompile Nginx again via centmin.sh menu option 4 and remove error_log debugging mode to disable Nginx debug mode again.

    To update your Centmin Mod builds code for Nginx debug mode support if you do not have a NGINX_DEBUG variable in centmin.sh, follow instructions at centminmod.com/upgrade.html and respective version threads below:
    Centmin Mod is provided as is, but you can try debugging mode for Nginx for further troubleshooting if you have problems with Nginx (i.e. segfaults / signal 11 issues) as outlined at nginx.org/en/docs/debugging_log.html & wiki.nginx.org/Debugging.
     
  7. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    Now, under debug mode for days, and I still cannot spot any useful error message (there are some 404 errors only).
     
  8. eva2000

    eva2000 Administrator Staff Member

    30,561
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,266
    Local Time:
    3:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    what are the exact 404 errors ?
     
  9. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    I've uploaded an error file (replaced the actual domain name)
     

    Attached Files:

  10. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    Hi eva2000, I wonder if you find any useful clue out of the error file yet? The problem still persisted, and I have to cancel using subdomain temporarily. T T
     
  11. eva2000

    eva2000 Administrator Staff Member

    30,561
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,266
    Local Time:
    3:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    nah.. looks like you'll have to figure it out yourself as centmin mod is provided as is, so for custom setups like yours you'd have to figure it out.
     
  12. jellday

    jellday New Member

    26
    2
    3
    May 31, 2014
    Ratings:
    +3
    Local Time:
    1:47 AM
    1.4.6
    5.5
    But everything was working perfect on the DO droplet which is using the old centminmod 08 stable (I think in the year 2015). After I recently migrated to Vultr, and using the new stable 08 version and the problem shows up. That's why I think it is related to centminmod.
     
  13. eva2000

    eva2000 Administrator Staff Member

    30,561
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,266
    Local Time:
    3:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    Unfortunately it is still a non standard configuration so troubleshooting would be up to you to do

    Maybe look through nginx and php change log histories to see what changed between the versions used on old DigitalOcean vs Vultr server too as well as 123.08stable commit history which has minimal changes other than some versions numbers for software like nginx and some fixes

    Also has the php script(s) in question been updated version wise since moving to Vultr ? If so I'd check the php script(s) version history too. What is the php script ?
     
    Last edited: Jul 24, 2017