1. map $request_uri $redirect_fbclid {
  2. "~^(.*?)([?&]fbclid=[a-zA-Z0-9_-]+)$" $1;
  3. }
  4. server {
  5. listen 80;
  6. server_name blog.rednet.ge;
  7. #return 301 https://blog.rednet.ge$request_uri;
  8. root /var/www/html/wordpress;
  9. }
  10. server {
  11. listen 443 ssl http2;
  12. server_name blog.rednet.ge;
  13. keepalive_timeout 70;
  14. ssl_certificate /etc/letsencrypt/live/blog.rednet.ge/fullchain.pem;
  15. ssl_certificate_key /etc/letsencrypt/live/blog.rednet.ge/privkey.pem;
  16. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  17. ssl_ciphers HIGH:!aNULL:!MD5;
  18. gzip on;
  19. gzip_static on;
  20. ssl_session_cache shared:SSL:10m;
  21. ssl_session_timeout 10m;
  22. charset UTF-8;
  23. root /var/www/html/wordpress;
  24. if ( $redirect_fbclid ) {
  25. return 301 $redirect_fbclid;
  26. }
  27. set $cache_uri $request_uri;
  28. # bypass cache if POST requests or URLs with a query string
  29. if ($request_method = POST) {
  30. set $cache_uri 'nullcache';
  31. }
  32. if ($query_string != "") {
  33. set $cache_uri 'nullcache';
  34. }
  35. # bypass cache if URLs containing the following strings
  36. if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)") {
  37. set $cache_uri 'nullcache';
  38. }
  39. # bypass cache if the cookies containing the following strings
  40. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
  41. set $cache_uri 'nullcache';
  42. }
  43. # default html file
  44. set $cache_enabler_uri '/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';
  45. location / {
  46. gzip_static on; # this directive is not required but recommended
  47. try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
  48. index index.html index.htm index.php;
  49. }
  50. #error_page 404 /404.html;
  51. # redirect server error pages to the static page /50x.html
  52. #
  53. error_page 500 502 503 504 /50x.html;
  54. location = /50x.html {
  55. root /usr/share/nginx/html;
  56. }
  57. location ~ \.php$ {
  58. try_files $uri =404;
  59. fastcgi_pass unix:/var/run/php-fpm.sock;
  60. fastcgi_index index.php;
  61. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  62. include fastcgi_params;
  63. }
  64. location ~* \.css$ {
  65. etag on;
  66. gzip_vary on;
  67. expires 30d;
  68. }
  69. location ~* \.js$ {
  70. etag on;
  71. gzip_vary on;
  72. expires 30d;
  73. }
  74. location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg)$ {
  75. etag on;
  76. expires 30d;
  77. }
  78. location ~ /\.ht {
  79. deny all;
  80. }
  81. }