Support » Plugin: WP Cloudflare Super Page Cache » How to do the nginx.conf on a vps?

  • I have a VPS running nginx with a few wordpress sites. Currently two are using your plugin, the others you the standard cloudflare plugin.

    There is a page “Nginx Settings > Browser caching rules”

        location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location = /wp-content/wp-cloudflare-super-page-cache/web.site/debug.log { access_log off; deny all; }

    Do I add it here: /etc/nginx/nginx.conf ?

    And since nginx.conf is for all sites on this server, will it interfere with the `others? And do I need to add like:
    location = /wp-content/wp-cloudflare-super-page-cache/web1.site/debug.log { access_log off; deny all;
    location = /wp-content/wp-cloudflare-super-page-cache/web2.site/debug.log { access_log off; deny all;
    location = /wp-content/wp-cloudflare-super-page-cache/web3.site/debug.log { access_log off; deny all;`

    I think this question might be FAQ worthy 😉

    With putting them in /etc/nginx/nginx.conf inside http{} tag nginx will not restart.

    • This topic was modified 6 months, 2 weeks ago by yellofish.
Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter yellofish

    (@yellofish)

    One added information: I use the wordops stack

    Now I tried putting it in: /etc/nginx/sites-available/web.site

    Nginx re-starts, site works, cache works.

    But no idea that is correct or not. Please let me know.

    • This reply was modified 6 months, 2 weeks ago by yellofish.
    • This reply was modified 6 months, 2 weeks ago by yellofish.
    Plugin Contributor Saumya Majumder

    (@isaumya)

    Hi @yellofish,
    You don’t need to manually add the nginx configs. WHen you install, activate & setup the plugin it will automatically create a nginx.conf file for you inside /wp-content/wp-cloudflare-super-page-cache/<domain-name>/ folder and you can simply include that file in your server’s main nginx.conf file and restart nginx. That’s it.

    Thread Starter yellofish

    (@yellofish)

    So I went to /etc/nginx/nginx.conf and added right after:

    	##
    	# Virtual Host Configs
    	##
    
    	include /etc/nginx/conf.d/*.conf;
    	include /etc/nginx/sites-enabled/*;

    …I added the line:

    include /var/www/web.site/htdocs/wp-content/wp-cloudflare-super-page-cache/web.site/nginx.conf;

    It’s not letting me re-start nginx, I get a re-start error.

    • This reply was modified 6 months, 2 weeks ago by yellofish.
    Plugin Contributor Saumya Majumder

    (@isaumya)

    Hi @yellofish,
    Maybe because you are in the /etc/ and you need to use a relative path? Not sure. You need to talk to a server admin for this or post in something like StackOverflow to see how to include things outside of the folder you are currently in.

    Thread Starter yellofish

    (@yellofish)

    Not working:

    include /var/www/web.site/htdocs/wp-content/wp-cloudflare-super-page-cache/web.site/nginx.conf;

    Working:

    include var/www/web.site/htdocs/wp-content/wp-cloudflare-super-page-cache/web.site/nginx.conf;

    nginx is full of wonders!

    Plugin Contributor Saumya Majumder

    (@isaumya)

    Hi @yellofish,
    You should either ask the WordOps community about how to include a Nginx file outside of the /etc/ folder or talk to a server admin.

    Thread Starter yellofish

    (@yellofish)

    Well, the includedoes not throw an error.

    Is there a way to actually test it? I mean all basic functions work.

    Plugin Contributor Saumya Majumder

    (@isaumya)

    Hi @yellofish,
    Ye you can check the response header and see the proper headers are being shown there or not which is present in the plugin nginx.conf file.

    Thread Starter yellofish

    (@yellofish)

    So when I get those line in the header all is fine and working I guess?

    no-store, no-cache, must-revalidate, max-age=0

    Debug.log is also adding data.

    Plugin Contributor Saumya Majumder

    (@isaumya)

    Yah check the static files like css, js, images and check if the browser caching rule is being applied there as well or not. If you share your site URL I can check it from here too.

    Thread Starter yellofish

    (@yellofish)

    Here are two site where I did set it up. Any suggestions are welcome

    https://iphone-worldwide.com (loads data from mysql)
    https://parodont-hk.com (a static site)

    Plugin Contributor Saumya Majumder

    (@isaumya)

    Hi @yellofish,
    It seems you didn’t enable the option of add a browser cache rule inside the plugin. You should do that as it adds the best possible version of cache control for your static files. On the first site, I can see the plugin working properly and things getting cached.

    But on the second one, I see the plugin working properly caching the initial HTML request but all the static files are not getting cached. Maybe you have some wired page rules or settings inside Cloudflare for that domain? Do note you don’t need any page rules to add the page rule the plugin adds automatically is all u need.

    I would recommend enabling the add browser cache rule option inside the plugin settings cache tab and restart your nginx.

    Thread Starter yellofish

    (@yellofish)

    Mhm, I need to check that.

    I think with your plugin I need to rules, right?

    https://i.imgur.com/2iuHoKR.png

    By the time you see them they are most likely removed.

    Plugin Contributor Saumya Majumder

    (@isaumya)

    yes you don’t need rule 1 and 2. Only the 3rd one added by the plugin is enough.

    Thread Starter yellofish

    (@yellofish)

    What about:

    Prevent the following URIs to be cached: /wp-* ?

    Should that be set

    And, so I still keep “Cache Level: Cache Everything” in CF, right?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘How to do the nginx.conf on a vps?’ is closed to new replies.