nginx won't accept snippets from domain options tab on one the websites

Discussion in 'Installation/Configuration' started by lonerunner, Jun 30, 2015.

  1. lonerunner

    lonerunner Member

    I have a few websites created on my server and 3 of them are on wordpress.

    All 3 websites have the same configuration, and all 3 websites should have the same nginx config.

    But on one of the websites, the last one i added nginx won't accept snippets i added in domain options tab. The other 2 websites works fine.

    As i checked in etc/nginx/sites-enabled/100-domainone.com.vhost
    The custom wordpress options from options tab are added there, also on domain 2.

    But the last domain i added don't have snippets added that i added in options tab. I thought maybe i copy/pasted something wrong when i activated wordpress cache plugin so i tried just with small code. Even if i use just a small snippet like

    Code:
    location / {
       try_files $uri $uri/ /index.php?$args;
    }
    This is recommended by wordpress codex. It doesn't work. If i check /etc/nginx/sites-enabled/100-domainthree.com.vhost i see just regular server config that is added by ispconfig on domain creation. when i visit the website under subpage i see 404 not found nginx error.

    Under error logs in ispconfig i didn't found anything about this error and also under nginx i didn't found anything. From earlier i noticed when i restart nginx and some of the config have errors nginx wont start.

    So why on first 2 domains the server accept params from options tab and on last one doesn't?

    This is recommended config from w3 total cache plugin and also from wordpress codex.

    Code:
    # Global restrictions configuration file.
    # Designed to be included in any server {} block.</p>
    location = /favicon.ico {
       log_not_found off;
       access_log off;
    }
    
    location = /robots.txt {
       allow all;
       log_not_found off;
       access_log off;
    }
    
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~ /\. {
       deny all;
    }
    
    # Deny access to any files with a .php extension in the uploads directory
    # Works in sub-directory installs and also in multisite network
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~* /(?:uploads|files)/.*\.php$ {
       deny all;
    }
    # WordPress single blog rules.
    # Designed to be included in any server {} block.
    
    # This order might seem weird - this is attempted to match last if rules below fail.
    # http://wiki.nginx.org/HttpCoreModule
    location / {
       try_files $uri $uri/ /index.php?$args;
    }
    
    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
    # Directives to send expires headers and turn off 404 error logging.
    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
      access_log off; log_not_found off; expires max;
    }
    
    # Uncomment one of the lines below for the appropriate caching plugin (if used).
    #include global/wordpress-wp-super-cache.conf;
    #include global/wordpress-w3-total-cache.conf;
    
    # Pass all .php files onto a php-fpm/php-fcgi server.
    location ~ [^/]\.php(/|$) {
       fastcgi_split_path_info ^(.+?\.php)(/.*)$;
       if (!-f $document_root$fastcgi_script_name) {
         return 404;
       }
       # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)
    
       include fastcgi.conf;
       fastcgi_index index.php;
    #   fastcgi_intercept_errors on;
       fastcgi_pass php;
    }
    
    # BEGIN W3TC Minify cache
    location ~ /wp-content/cache/minify.*\.js$ {
      types {}
      default_type application/x-javascript;
      expires modified 31536000s;
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
      add_header Vary "Accept-Encoding";
      add_header Pragma "public";
      add_header Cache-Control "max-age=31536000, public";
    }
    location ~ /wp-content/cache/minify.*\.css$ {
      types {}
      default_type text/css;
      expires modified 31536000s;
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
      add_header Vary "Accept-Encoding";
      add_header Pragma "public";
      add_header Cache-Control "max-age=31536000, public";
    }
    location ~ /wp-content/cache/minify.*js\.gzip$ {
      gzip off;
      types {}
      default_type application/x-javascript;
      expires modified 31536000s;
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
      add_header Vary "Accept-Encoding";
      add_header Pragma "public";
      add_header Cache-Control "max-age=31536000, public";
      add_header Content-Encoding gzip;
    }
    location ~ /wp-content/cache/minify.*css\.gzip$ {
      gzip off;
      types {}
      default_type text/css;
      expires modified 31536000s;
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
      add_header Vary "Accept-Encoding";
      add_header Pragma "public";
      add_header Cache-Control "max-age=31536000, public";
      add_header Content-Encoding gzip;
    }
    # END W3TC Minify cache
    # BEGIN W3TC Page Cache cache
    location ~ /wp-content/cache/page_enhanced.*html$ {
      expires modified 3600s;
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
      add_header Vary "Accept-Encoding, Cookie";
      add_header Pragma "public";
      add_header Cache-Control "max-age=3600, public";
    }
    location ~ /wp-content/cache/page_enhanced.*gzip$ {
      gzip off;
      types {}
      default_type text/html;
      expires modified 3600s;
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
      add_header Vary "Accept-Encoding, Cookie";
      add_header Pragma "public";
      add_header Cache-Control "max-age=3600, public";
      add_header Content-Encoding gzip;
    }
    # END W3TC Page Cache cache
    # BEGIN W3TC Browser Cache
    gzip on;
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
    location ~ \.(css|htc|less|js|js2|js3|js4)$ {
      expires 31536000s;
      add_header Pragma "public";
      add_header Cache-Control "max-age=31536000, public";
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
    }
    location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
      expires 3600s;
      add_header Pragma "public";
      add_header Cache-Control "max-age=3600, public";
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
    }
    location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip)$ {
      expires 31536000s;
      add_header Pragma "public";
      add_header Cache-Control "max-age=31536000, public";
      add_header X-Powered-By "W3 Total Cache/0.9.4.1";
    }
    # END W3TC Browser Cache
    # BEGIN W3TC Minify core
    rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last;
    set $w3tc_enc "";
    if ($http_accept_encoding ~ gzip) {
      set $w3tc_enc .gzip;
    }
    if (-f $request_filename$w3tc_enc) {
      rewrite (.*) $1$w3tc_enc break;
    }
    rewrite ^/wp-content/cache/minify/(.+/[X]+\.css)$ /wp-content/plugins/w3-total-cache/pub/minify.php?test_file=$1 last;
    rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1 last;
    # END W3TC Minify core
    # BEGIN W3TC Page Cache core
    set $w3tc_rewrite 1;
    if ($request_method = POST) {
      set $w3tc_rewrite 0;
    }
    if ($query_string != "") {
      set $w3tc_rewrite 0;
    }
    if ($request_uri !~ \/$) {
      set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)") {
      set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(w3tc_preview)") {
      set $w3tc_rewrite _preview;
    }
    set $w3tc_enc "";
    if ($http_accept_encoding ~ gzip) {
      set $w3tc_enc _gzip;
    }
    set $w3tc_ext "";
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.html$w3tc_enc") {
      set $w3tc_ext .html;
    }
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.xml$w3tc_enc") {
      set $w3tc_ext .xml;
    }
    if ($w3tc_ext = "") {
      set $w3tc_rewrite 0;
    }
    if ($w3tc_rewrite = 1) {
      rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite$w3tc_ext$w3tc_enc" last;
    }
    # END W3TC Page Cache core
    Note to Admins or Moderators, im sorry i posted thread in wrong section. it was meant to go in ispconfig not linux section of installation/configuration. If someone read this i can't move thread now. Sorry.

    EDIT: I tried to manually add config in sites-available/100-sitethree.com.vhosts and restarted nginx and it accepted the config. When i browse the site now it works normally. But when i try to change something insite options tab under ispconfig it reverts the config to default and wont' accept parameters.
     
    Last edited: Jun 30, 2015
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The problem is that you are actually duplicating some config that exists in the vhost genereated by ispconfig and therefor nginx has to reject it. Try to remove:

    # Pass all .php files onto a php-fpm/php-fcgi server.
    location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
    return 404;
    }
    # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)

    include fastcgi.conf;
    fastcgi_index index.php;
    # fastcgi_intercept_errors on;
    fastcgi_pass php;
    }

    as thats not needed on a ispconfig server.
     
  3. lonerunner

    lonerunner Member

    Thanks for the reply till, i noticed that i was duplicating some of the config so i removed that but that was not an issue. The problem relied due to missing fastcgi.conf file i just don't understand how it accepted it on first two domains and didn't on third one.

    After i removed

    Code:
    include fastcgi.conf;
    fastcgi_index index.php;
    # fastcgi_intercept_errors on;
    fastcgi_pass php;
    it started to work.
    Does it mean i dont have fastcgi or something is missconfigured. I searched for fastcgi.conf file and i didn't found it on a server. But looking at server phpinfo it states that i have fastcgi.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    You have fastcgi and there is no fastcgi.conf required. This fastcgi.conf file might be a file from a different kind of crontrolpanel, ispconfig does not require or use that file.
     
    lonerunner likes this.

Share This Page