Get the most out of your Centmin Mod LEMP stack
Become a Member

Wordpress and Brotli

Discussion in 'Blogs & CMS usage' started by ahmed, Mar 11, 2017.

  1. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    I just enabled it and add all the required configs, However Im getting 404 and 500 errors

    any idea?
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,862
    6,905
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,397
    Local Time:
    2:55 AM
    Nginx 1.13.x
    MariaDB 5.5
    what are specific errors or page urls where you are getting 404/500 ?

    can you outline the steps you did ?

    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)

    what is output of these commands in ssh
    Code (Text):
    curl -I https://domain.com
    

    Code (Text):
    curl -I https://www.domain.com
    

    Code (Text):
    curl -I http://domain.com
    

    Code (Text):
    curl -I http://www.domain.com
    

    wrap output in CODE tags
     
  3. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    what are specific errors or page urls where you are getting 404/500 ?
    any wordpress page on front end shows 404
    editing the permialinl on backend shows 500
    I had thirparty live chat plugin it shows 500 on front end too

    can you outline the steps you did ?

    the same as tutorial

    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)

    sent to ur PM

    what is output of these commands in ssh
    Code (Text):
    curl -I https://domain.com
    

    Code (Text):
    curl -I https://www.domain.com
    

    Code (Text):
    curl -I http://domain.com
    

    Code (Text):
    curl -I http://www.domain.com
    

    wrap output in CODE tags[/QUOTE]
     
  4. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    Code (Text):
    
      #try_files    $uri $uri/ /index.php;
    
    
    
    
    
      }
    
    
    
    
    
      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;
    
    
    
    }
    
    




    Code (Text):
    
    [18:14][root@wordpress1 centminmod]# curl -I https://replaceddomain.com
    
    
    
    HTTP/1.1 200 OK
    
    
    
    Date: Fri, 10 Mar 2017 18:14:48 GMT
    
    
    
    Content-Type: text/html; charset=UTF-8
    
    
    
    Connection: keep-alive
    
    
    
    Vary: Accept-Encoding
    
    
    
    Set-Cookie: PHPSESSID=9q8bgp6g0dnasnj6214ocjm6al; path=/
    
    
    
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    
    
    
    Cache-Control: no-store, no-cache, must-revalidate
    
    
    
    Pragma: no-cache
    
    
    
    Set-Cookie: wordpress_logged_in_084e0343a0486ff05530df6c705c8bb4=09d1c0611a453caf35b31af20358ac60; expires=Fri, 10-Mar-2017 19:14:48 GMT; Max-Age=3600
    
    
    
    Set-Cookie: learn_press_user_guest_id=1489169688; expires=Fri, 10-Mar-2017 20:14:48 GMT; Max-Age=7200; path=/
    
    
    
    Link: <https://replaceddomain.com/wp-json/>; rel="https://api.w.org/"
    
    
    
    Link: <https://replaceddomain.com/>; rel=shortlink
    
    
    
    Server: nginx centminmod
    
    
    
    X-Powered-By: centminmod
    
    




    Code (Text):
    
    [18:14][root@wordpress1 centminmod]# curl -I https://www.replaceddomain.com
    
    
    
    HTTP/1.1 301 Moved Permanently
    
    
    
    Date: Fri, 10 Mar 2017 18:16:16 GMT
    
    
    
    Content-Type: text/html; charset=UTF-8
    
    
    
    Connection: keep-alive
    
    
    
    Set-Cookie: PHPSESSID=ik5v18qck4rjrgitsueuudkbv2; path=/
    
    
    
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    
    
    
    Cache-Control: no-store, no-cache, must-revalidate
    
    
    
    Pragma: no-cache
    
    
    
    Set-Cookie: wordpress_logged_in_084e0343a0486ff05530df6c705c8bb4=e616f61c786bcc143cead19496f1fe84; expires=Fri, 10-Mar-2017 19:16:16 GMT; Max-Age=3600
    
    
    
    Set-Cookie: learn_press_user_guest_id=1489169776; expires=Fri, 10-Mar-2017 20:16:16 GMT; Max-Age=7200; path=/
    
    
    
    Location: https://replaceddomain.com/
    
    
    
    Server: nginx centminmod
    
    
    
    X-Powered-By: centminmod
    
    
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,862
    6,905
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,397
    Local Time:
    2:55 AM
    Nginx 1.13.x
    MariaDB 5.5
    to post on forums, search and replace the text to mask your domain name if you don't want it publicly shown

    tutorial also outlins HTTPS ssl setup, did you do that too https://community.centminmod.com/posts/45825/ ?
    which did you follow ? if you had existing Nginx HTTP site, you should use 2nd method if you wanted to switch to HTTPS, otherwise first method might of screwed up your existing Nginx vhost.

    Or was your domain a fresh one never setup on server, and used first method ?

    Or didn't do these and only enabled ngx_brotli as per 1st post at https://community.centminmod.com/th...sion-for-centmin-mod-nginx-web-servers.10688/ ?
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,862
    6,905
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,397
    Local Time:
    2:55 AM
    Nginx 1.13.x
    MariaDB 5.5
    your posted output is missing portions of the contents, ensure your SSH client's scroll buffer and window size is large enough to show entire output of this command
    Code (Text):
    cat /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    

    and
    Code (Text):
    cat /usr/local/nginx/conf/conf.d/newdomain.com.conf
    

    where newdomain.com is yourdomain.com

    example output of 2nd command
    Code (Text):
    cat /usr/local/nginx/conf/conf.d/newdomain.com.conf
    
    # 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 newdomain.com 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;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
    
      # 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;
    
      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;
    
      }
    
      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;
    }
    
     
  7. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    Code (Text):
    
    [18:27][root@wordpress1 centminmod]# cat /usr/local/nginx/conf/conf.d/replaceddomain.com.ssl.conf
    
    # Centmin Mod Getting Started Guide
    
    # must read http://centminmod.com/getstarted.html
    
    # For HTTP/2 SSL Setup
    
    # read http://centminmod.com/nginx_configure_https_ssl_spdy.html
    
    
    
    # redirect from www to non-www  forced SSL
    
    # uncomment, save file and restart Nginx to enable
    
    # if unsure use return 302 before using return 301
    
     server {
    
       server_name replaceddomain.com www.replaceddomain.com;
    
        return 302 https://replaceddomain.com$request_uri;
    
     }
    
    
    
    server {
    
      listen 443 ssl http2;
    
      server_name replaceddomain.com www.replaceddomain.com;
    
    
    
      ssl_dhparam /usr/local/nginx/conf/ssl/replaceddomain.com/dhparam.pem;
    
      ssl_certificate      /usr/local/nginx/conf/ssl/replaceddomain.com/replaceddomain.com-acme.cer;
    
      ssl_certificate_key  /usr/local/nginx/conf/ssl/replaceddomain.com/replaceddomain.com-acme.key;
    
      include /usr/local/nginx/conf/ssl_include.conf;
    
    
    
      http2_max_field_size 16k;
    
      http2_max_header_size 32k;
    
      # dual cert supported ssl ciphers
    
      ssl_ciphers     EECDH+CHACHA20-draft:EECDH+CHACHA20:EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+ECDSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+SHA384:EECDH+AES128:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
    
      ssl_prefer_server_ciphers   on;
    
      #add_header Alternate-Protocol  443:npn-spdy/3;
    
      #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
    
      #add_header X-Frame-Options SAMEORIGIN;
    
      #add_header X-Xss-Protection "1; mode=block" always;
    
      #add_header X-Content-Type-Options "nosniff" always;
    
      #spdy_headers_comp 5;
    
      ssl_buffer_size 1369;
    
      ssl_session_tickets on;
    
     
    
      # enable ocsp stapling
    
      resolver 8.8.8.8 8.8.4.4 valid=10m;
    
      resolver_timeout 10s;
    
      ssl_stapling on;
    
      ssl_stapling_verify on;
    
      ssl_trusted_certificate /usr/local/nginx/conf/ssl/replaceddomain.com/replaceddomain.com-acme.cer;
    
    
    
    # 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/replaceddomain.com/log/access.log combined buffer=256k flush=60m;
    
      error_log /home/nginx/domains/replaceddomain.com/log/error.log;
    
    
    
      root /home/nginx/domains/replaceddomain.com/public;
    
    
    
      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;
    
    
    
      }
    
    
    
      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;
    
    }
    
    [18:27][root@wordpress1 centminmod]# 
    
    
     
  8. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    Code (Text):
    
    [18:30][root@wordpress1 centminmod]# cat /usr/local/nginx/conf/conf.d/domain.com.conf
    
    cat: /usr/local/nginx/conf/conf.d/domain.com.conf: No such file or directory
    
    [18:30][root@wordpress1 centminmod]#
    
    
     
  9. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    - I followed the guide of migrating an http site to https
     
  10. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    if there is a problem in the setup, I can delete the domain and start from the scratch
     
  11. eva2000

    eva2000 Administrator Staff Member

    30,862
    6,905
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,397
    Local Time:
    2:55 AM
    Nginx 1.13.x
    MariaDB 5.5
    you need to follow step 7 to the letter Migrating Existing Nginx Vhost From HTTP to HTTP/2 based HTTPS With Letsencrypt SSL Certificates

    so your wordpress nginx rules were in /usr/local/nginx/conf/conf.d/newdomain.com.conf but you didn't migrate those to /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf so that is why you're getting errors in wordpress

    You can see an example of http vs https version of basic wordpress nginx vhost using official vhost generator at Generate Centmin Mod Nginx Vhost - CentminMod.com LEMP Nginx web stack for CentOS input domain name select http or https (ssl) checkbox and dropdown menu select basic wordpress and see what differs between a http and https vhost - that won't be exactly the same as your http vs https vhost files but you will get an idea of what wordpress nginx rules were in /usr/local/nginx/conf/conf.d/newdomain.com.conf that need migrating to /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf to get back your wordpress functionality
     
    Last edited: Mar 11, 2017
  12. ahmed

    ahmed Member

    223
    17
    18
    Feb 21, 2017
    Ratings:
    +23
    Local Time:
    6:55 PM
    thanks a lot eva for the effort you are putting to help us in this forum, I missed that message, and installed the wordpress from the scratch and it worked just fine