Advertisement
ioptimist

Untitled

Apr 2nd, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. Here are my configs:
  2. Took me about 2 weeks to make them work.
  3.  
  4. [code]#AUTOMATICALLY GENERATED - DO NO EDIT!
  5.  
  6. fastcgi_hide_header X-Powered-By;
  7. fastcgi_cache_path /srv/cache levels=1:2 keys_zone=MYAPP:500m inactive=60m;
  8. fastcgi_cache_key "$scheme$request_method$host$request_uri";
  9. client_max_body_size 128m;
  10.  
  11. server {
  12. listen 80;
  13. server_name example.com www.example.com;
  14. return 301 https://example.com$request_uri;
  15. }
  16. server {
  17. listen *:443 ssl http2;
  18. ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
  19. ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
  20. server_name example.com;
  21. access_log /var/log/nginx/example.access.log;
  22. error_log /var/log/nginx/example.error.log;
  23. root /srv/example.com;
  24. index index.html index.htm index.php;
  25.  
  26. include /srv/conf/example.conf; #modx part goes here
  27.  
  28. location ~ [^/]\.php(/|$) {
  29. add_header Strict-Transport-Security max-age=15768000;
  30. fastcgi_cache MYAPP;
  31. fastcgi_cache_valid 200 60m;
  32. add_header X-Cache $upstream_cache_status;
  33. set $no_cache 0;
  34. if ($request_uri ~* "/(manager/)")
  35. {
  36. set $no_cache 1;
  37. }
  38. fastcgi_cache_bypass $no_cache;
  39. fastcgi_no_cache $no_cache;
  40. # serve static files directly
  41. location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
  42. root /srv/example.com;
  43. access_log off;
  44. expires 30d;
  45. break;
  46. }
  47.  
  48. fastcgi_index index.php;
  49. include fcgi.conf;
  50. fastcgi_pass unix:/var/run/ajenti-v-php-fcgi-examplecom-php-fcgi-0.sock;
  51. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  52.  
  53. }
  54.  
  55. }[/code]
  56.  
  57. [quote]include /srv/conf/example.conf;[/quote] is a modx config
  58. [code]charset utf-8;
  59. autoindex off;
  60. include /srv/conf/basic.conf;
  61. include /srv/conf/additional.conf;
  62.  
  63. access_log off;
  64. log_not_found off;
  65. error_log /var/log/nginx/nginx-error.log warn;
  66. location = /favicon.ico { access_log off; log_not_found off; }
  67. location = /robots.txt { access_log off; log_not_found off; }
  68.  
  69. #MODX IMPORTANT
  70. location /manager {
  71. }
  72. location /assets {
  73. }
  74. location / {
  75. #try to get file directly, try it as a directory or fall back to modx
  76. try_files $uri $uri/ @modx;
  77. }
  78. location @modx {
  79. #including ? in second rewrite argument causes nginx to drop GET params, so append them again
  80. rewrite ^/(.*)$ /index.php?q=$1&$args;
  81. }[/code]
  82.  
  83. [quote]include /srv/conf/basic.conf;[/quote]
  84. Its [url=https://github.com/h5bp/server-configs-nginx]h5bp/server-configs-nginx[/url]. They are handy for SSL and other optimisations. Play them if you need.
  85.  
  86. [quote]include /srv/conf/additional.conf;[/quote]
  87. Gzip optimisation
  88. [code]#keepalive_timeout 20s;
  89. sendfile on;
  90. tcp_nopush on;
  91. gzip on;
  92. gzip_comp_level 5;
  93. gzip_min_length 256;
  94. gzip_proxied any;
  95. gzip_vary on;
  96. gzip_types
  97. application/atom+xml
  98. application/javascript
  99. application/json
  100. application/ld+json
  101. application/manifest+json
  102. application/rss+xml
  103. application/vnd.geo+json
  104. application/vnd.ms-fontobject
  105. application/x-font-ttf
  106. application/x-web-app-manifest+json
  107. application/xhtml+xml
  108. application/xml
  109. font/opentype
  110. image/bmp
  111. image/svg+xml
  112. image/x-icon
  113. text/cache-manifest
  114. text/css
  115. text/plain
  116. text/vcard
  117. text/vnd.rim.location.xloc
  118. text/vtt
  119. text/x-component
  120. text/x-cross-domain-policy;
  121.  
  122. [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement