Coder Social home page Coder Social logo

pothi / wordpress-nginx Goto Github PK

View Code? Open in Web Editor NEW
391.0 35.0 83.0 223 KB

WordPress specific Nginx configuration templates and best practices!

Home Page: https://www.tinywp.in

License: MIT License

Nginx 100.00%
wordpress-nginx wordpress nginx debian ubuntu centos

wordpress-nginx's Issues

https_suffix.html problem

Hello. I truly thank you for sharing useful information.

I applied Wp-rocket.conf in your Github onto Nginx which I am using,

but an error occurs that https_suffix.html file can't be found.

I am using rocket, but I can't create the file. Could you tell me what I should do about this matter?

Thank you.

$wpsc

Hello,
where does $wpsc variable comes from in wprocket.conf? That sounds like WordPress SuperCache?

Which files should I review to learn more about multisite configuration?

I run a 100+ site multisite network which is configured to use sub domains. I'm experimenting with migrating from our existing Apache server to Nginx, but the tutorials I find online all have varying or conflicting information depending on the age of the tutorial.

To learn how modern multisite configurations work, which of your files should I review for reference?

If I followed the instructions to download and implement these files, do I need to do anything in particular to get this working correctly with a subdomain setup? Or should this just work after I drop it in?

Running:
Ubuntu 18.04 bionic
nginx 1.14
Wordpress 4.9.7 with PHP 7.2
Using cloudflare free, if that matters

About Rocket-nginx.

Hi,

If I use WIB or Wordpress-nginx, is it okay to not use Rocket Nginx? Also I am using Woocommerce, and is it okay to use it as it is without any additional setting?

Thank you.

Feature Request: NGINX's FastCGI cache

For those prefer to use NGINX's native FastCGI cache instead of php based plugins. Feel free to modify and add to globals directory.

fastcgi_cache_path /var/run/nginx-cache levels=1:2       
                   keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

server {
    server_name example.com www.example.com;
    root /var/www/example.com/htdocs;
    index index.php;

    access_log /var/log/nginx/example.com.access.log;
    error_log  /var/log/nginx/example.com.error.log;

    set $skip_cache 0;

    # POST requests and URLs with a query string should always go to PHP
    if ($request_method = POST) {
        set $skip_cache 1;
    }   

    if ($query_string != "") {
        set $skip_cache 1;
    }   

    # Don't cache URIs containing the following segments
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php
                         |sitemap(_index)?.xml") {
        set $skip_cache 1;
    }   

    # Don't use the cache for logged-in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass
        |wordpress_no_cache|wordpress_logged_in") {
        set $skip_cache 1;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }    

    location ~ \.php$ {
        try_files $uri /index.php;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        fastcgi_cache WORDPRESS;
        fastcgi_cache_valid  60m;
    }

    location ~ /purge(/.*) {
        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
    }	

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|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;
    }

    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    location ~ /\. {
        deny  all; 
        access_log off;
        log_not_found off;
    }
}

Mobile Compatibility for WP Super Cache

More and more sites are now compatible with mobile devices, either using responsive web design or by using a plugin specifically for mobile (ex: WPTouch). Let's make the configs compatible with such plugins and WP Super Cache plugin.

Wp Rocket Nginx Question

Inside location you have put:

expired modified 30m;
add_header "Cache-Control" "must-revalidate";

Wouldn't the following be better?
add_header Cache-Control "max-age=1800, must-revalidate";

Incredible. Thank you!

Sometimes, you have to drop a comment just because you are gobsmacked that someone did such an incredible job. Absolutely amazing.
Thank you!

I know you do $50/hour, but you got a donate page by chance? :P
Owe you a coffee at least... at least.

Anyway, thank you so much for this repo and all the effort you put into it. It shows clearly.

Not compatible with WooCommerce?

As I know we have to exclude the WooCommerce cookies on wp-rocket to avoid cart/checkout being cache . However, when I excluded them, I got 403 all the time.

if ($http_cookie ~* "woocommerce_items_in_cart") { return 418; }
if ($http_cookie ~* "woocommerce_cart_hash") { return 418; }
if ($http_cookie ~* "wp_woocommerce_session_") { return 418; }

force trailing slash to front end only.

Do you have a clever way of forcing trailing slashes to URLS on the front

/about-us/
/contact/our-team/

but leave the slash off

/wp-includes/js/file.js

We noticed that when you force trailing slashes, we could use the backend to update posts.

No more..

git clone git://github.com/pothi/wordpress-nginx.git $HOME/git/wordpress-nginx
should be
git clone https://github.com/pothi/wordpress-nginx.git $HOME/git/wordpress-nginx

common-locations.conf not found

It seems that many conf files contain this file

include "globals/common-locations.conf";

However I could not find this file.

can you help me

Hi,
First, i would like to thank you for your contribution, it amazes me how someone could put effort like this just to help noobies like me.
I followed your instructions but I can't get it to work. I'm getting "This site can’t be reached" when i try to access my domain.
below is the text I used in the mydomain.com.conf, my wordpress installation is not complete.
Could you please help me?
`

server {
listen 80;
listen [::]:80; # IPv6 support
server_name mydomain.com; 
index index.php; # default file to serve
root /usr/share/nginx/html;
access_log /var/log/nginx/example.com-access.log;

error_log /var/log/nginx/mydomain.com-error.log;

include "globals/restrictions.conf";
include "globals/assets.conf";

location ~* \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) { return 404; }

    fastcgi_param HTTP_PROXY "";

    include "fastcgi_params";
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_index               index.php;
    fastcgi_pass                fpm;

    add_header "X-Cache" "MISS";  }}`

Great work. Question about wp-super-cache conf for Nginx

This is about this file. Many thanks for sharing this! --
https://github.com/pothi/wordpress-nginx/blob/master/globals/wp-super-cache.conf

I can figure out from it what the 418 and 419 mean. We do it with the 'skip_cache' version found in some forums online. Same thing.

Question: the @mobileaccess directive has:

/wp-content/cache/supercache/$host${uri}index$https_suffix-mobile.html

What's the "suffix-mobile"? Our theme is completely responsive. Same pages and URLs get served to all devices. Is this still relevant to us?

Thanks.

add_header is being overwritten by location blocks

For what you've written for caching plugins, the / location would be evaluated first. However, given that you have locations for assets and .php the LAST location to be executed will write the headers. So , for example in example.com.conf, if you include any of the caching plugins you'll always see the header X-CACHE MISS. Even though the locations are being executed the last location to be executed will add the headers.

Per http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header

There could be several add_header directives. These directives are inherited from the previous level if and only if there are no add_header directives defined on the current level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.