Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here are my configs:
- Took me about 2 weeks to make them work.
- [code]#AUTOMATICALLY GENERATED - DO NO EDIT!
- fastcgi_hide_header X-Powered-By;
- fastcgi_cache_path /srv/cache levels=1:2 keys_zone=MYAPP:500m inactive=60m;
- fastcgi_cache_key "$scheme$request_method$host$request_uri";
- client_max_body_size 128m;
- server {
- listen 80;
- server_name example.com www.example.com;
- return 301 https://example.com$request_uri;
- }
- server {
- listen *:443 ssl http2;
- ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
- ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
- server_name example.com;
- access_log /var/log/nginx/example.access.log;
- error_log /var/log/nginx/example.error.log;
- root /srv/example.com;
- index index.html index.htm index.php;
- include /srv/conf/example.conf; #modx part goes here
- location ~ [^/]\.php(/|$) {
- add_header Strict-Transport-Security max-age=15768000;
- fastcgi_cache MYAPP;
- fastcgi_cache_valid 200 60m;
- add_header X-Cache $upstream_cache_status;
- set $no_cache 0;
- if ($request_uri ~* "/(manager/)")
- {
- set $no_cache 1;
- }
- fastcgi_cache_bypass $no_cache;
- fastcgi_no_cache $no_cache;
- # serve static files directly
- location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
- root /srv/example.com;
- access_log off;
- expires 30d;
- break;
- }
- fastcgi_index index.php;
- include fcgi.conf;
- fastcgi_pass unix:/var/run/ajenti-v-php-fcgi-examplecom-php-fcgi-0.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- }[/code]
- [quote]include /srv/conf/example.conf;[/quote] is a modx config
- [code]charset utf-8;
- autoindex off;
- include /srv/conf/basic.conf;
- include /srv/conf/additional.conf;
- access_log off;
- log_not_found off;
- error_log /var/log/nginx/nginx-error.log warn;
- location = /favicon.ico { access_log off; log_not_found off; }
- location = /robots.txt { access_log off; log_not_found off; }
- #MODX IMPORTANT
- location /manager {
- }
- location /assets {
- }
- location / {
- #try to get file directly, try it as a directory or fall back to modx
- try_files $uri $uri/ @modx;
- }
- location @modx {
- #including ? in second rewrite argument causes nginx to drop GET params, so append them again
- rewrite ^/(.*)$ /index.php?q=$1&$args;
- }[/code]
- [quote]include /srv/conf/basic.conf;[/quote]
- 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.
- [quote]include /srv/conf/additional.conf;[/quote]
- Gzip optimisation
- [code]#keepalive_timeout 20s;
- sendfile on;
- tcp_nopush on;
- gzip on;
- gzip_comp_level 5;
- gzip_min_length 256;
- gzip_proxied any;
- gzip_vary on;
- gzip_types
- application/atom+xml
- application/javascript
- application/json
- application/ld+json
- application/manifest+json
- application/rss+xml
- application/vnd.geo+json
- application/vnd.ms-fontobject
- application/x-font-ttf
- application/x-web-app-manifest+json
- application/xhtml+xml
- application/xml
- font/opentype
- image/bmp
- image/svg+xml
- image/x-icon
- text/cache-manifest
- text/css
- text/plain
- text/vcard
- text/vnd.rim.location.xloc
- text/vtt
- text/x-component
- text/x-cross-domain-policy;
- [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement