5/5 - (2 votes)
  • Login into server over SSH with ‘centos’ login.
  • Switch to the root user by command:
     sudo bash
  • Go to config directory of your website user:
    cd /home/promorri/conf/web

    (change ‘promorri’ to your user)

  •  Open general config file with any text editor, for example:
    mcedit nginx.conf
  •  Find section of your domain and in the end of the section you will see the line like this:
     include /home/promorri/conf/web/nginx.promo.com.conf*;
  • Create additional config file regarding this line, for example:
    touch /home/promorri/conf/web/nginx.promo.com.conf_pagespeed.conf
  • Open this file with text editor and add few lines:
    mcedit /home/promorri/conf/web/nginx.promo.com.conf_pagespeed.conf
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/ngx_pagespeed_static/" {
}
location ~ "^/ngx_pagespeed_beacon$" {
}
  • When file will be create and lines added you must restart nginx service to apply new settings. To do this you should run command:
    service nginx restart

    Also before restarting service you can check config syntax by running this command:

    nginx -t
  •  After all of this steps your domain should be optimized by pagespeed module.

Disabling pagespeed for domain.

  • Login into server over SSH with ‘centos’ login.
  • Switch to the root user by command:
    sudo bash
  • Go to config directory of your website user:
     cd /home/promorri/conf/web

    (change ‘promorri’ to your user)

  • Remove or move out from the folder addition config file which you created before. You can do this by running these commands (first command will move file to the /tmp directory and the second will delete it):
    mv nginx.promo.com.conf_pagespeed.conf /tmp
    rm nginx.promo.com.conf_pagespeed.conf
  • Then you must restart ngixn service to apply new configuration. To do this you should run command:
    service nginx restart

    Also before restarting service you can check config syntax by running this command:

    nginx -t

PLEASE do not change anything in main nconfiguration file nginx.conf. Yum must work only with addition config files which you created.