Skip to content

Instantly share code, notes, and snippets.

@masudcsesust04
Forked from lukeburden/nginx_blog.conf
Created August 20, 2019 10:49
Show Gist options
  • Save masudcsesust04/d1b3f56c9d319ef7441240f82ff002aa to your computer and use it in GitHub Desktop.
Save masudcsesust04/d1b3f56c9d319ef7441240f82ff002aa to your computer and use it in GitHub Desktop.

Revisions

  1. @lukeburden lukeburden renamed this gist Apr 26, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @lukeburden lukeburden revised this gist Apr 26, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@ proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=blog_cache:1m max_size=10

    server{
    listen 80;
    server_name www.example.com;
    server_name example.com;

    # prevent forwarding of cookies and unnecessary headers
    # prevent forwarding of cookies
    proxy_set_header Cookie "";

    # prevent passing of WP cookie back to client
    @@ -24,7 +24,7 @@ server{

    # replace all instances of the WPEngine subdomain from the response
    subs_filter_types text/html text/css text/xml;
    subs_filter 'exampleblog.wpengine.com' 'www.example.com/blog' gi;
    subs_filter 'exampleblog.wpengine.com' 'example.com/blog' gi;

    }

  3. @lukeburden lukeburden revised this gist Apr 24, 2018. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -4,11 +4,6 @@ server{
    listen 80;
    server_name www.example.com;

    # redirect HTTP traffic to HTTPS
    if ($http_x_forwarded_proto = "http") {
    rewrite ^(.*)$ https://$server_name$1 permanent;
    }

    # prevent forwarding of cookies and unnecessary headers
    proxy_set_header Cookie "";

    @@ -34,7 +29,7 @@ server{
    }

    # we cache all content for 60 minutes, ignoring WPEngine cache
    # headers but not caching some most errors
    # headers but not caching most errors
    proxy_cache blog_cache;
    proxy_ignore_headers Cache-Control;
    proxy_cache_valid 200 302 60m;
  4. @lukeburden lukeburden revised this gist Apr 24, 2018. No changes.
  5. @lukeburden lukeburden created this gist Apr 24, 2018.
    42 changes: 42 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=blog_cache:1m max_size=100m inactive=60m use_temp_path=off;

    server{
    listen 80;
    server_name www.example.com;

    # redirect HTTP traffic to HTTPS
    if ($http_x_forwarded_proto = "http") {
    rewrite ^(.*)$ https://$server_name$1 permanent;
    }

    # prevent forwarding of cookies and unnecessary headers
    proxy_set_header Cookie "";

    # prevent passing of WP cookie back to client
    proxy_hide_header Set-Cookie;

    # hide a range of other, unimportant headers
    proxy_hide_header link;
    proxy_hide_header wpe-backend;
    proxy_hide_header x-pingback;

    location /blog/ {
    proxy_pass https://exampleblog.wpengine.com:443/;
    proxy_set_header Host exampleblog.wpengine.com;

    # strip /blog/ from the path
    rewrite /blog/(.*) /$1 break;

    # replace all instances of the WPEngine subdomain from the response
    subs_filter_types text/html text/css text/xml;
    subs_filter 'exampleblog.wpengine.com' 'www.example.com/blog' gi;

    }

    # we cache all content for 60 minutes, ignoring WPEngine cache
    # headers but not caching some most errors
    proxy_cache blog_cache;
    proxy_ignore_headers Cache-Control;
    proxy_cache_valid 200 302 60m;
    proxy_cache_valid 404 10m;
    }