En wordpress sajt med W3C ska man således ha följande konfig.
server { server_name www.minsajt.se; return 301 $scheme://minsajt.se$request_uri; } server { listen 80; listen [::]:80; index index.html index.htm index.php; # Here you can set a server name, you can use wildcards such as *.example.com # however remember if you use server_name *.example.com; You'll only match subdomains # to match both subdomains and the main domain use both example.com and *.example.com server_name www.minsajt.se; root /var/www/minsajt.se; client_max_body_size 7M; # It's always good to set logs, note however you cannot turn off the error log # setting error_log off; will simply create a file called 'off'. access_log off; error_log /var/log/nginx/minsajt.error.log; include ifblacklist.conf; include wordpress_w3_cache.conf; location ~ \.php$ { include fastcgi_conf; } include wordpress-sitemap.conf; include static.conf; include drop.conf; }
Vill man istället köra wordpress med fastcgi cache:
server { listen 80; listen [::]:80; index index.php index.html; server_name minsajt.se; access_log off; # access_log /var/log/nginx/minsajt.access.log; error_log /var/log/nginx/minsajt.error.log; root /var/www/minsajt.se; client_max_body_size 7M; index index.html index.php; include ifblacklist.conf; include wordpress_fastcgi_cache.conf; location ~ \.php$ { include fastcgi_conf; #för fastcgi cache nedan fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache PHPCACHE; fastcgi_cache_valid 60m; fastcgi_cache_use_stale updating error timeout invalid_header http_500; fastcgi_cache_revalidate on; #nedan for kunna rensa sidor ur cache med scriptet tabortfiler add_header X-Cached $upstream_cache_status; fastcgi_cache_bypass $http_cache_purge; add_header X-Frame-Options sameorigin; } include wordpress-sitemap.conf; include static.conf; include drop.conf; }
Inställningar för en mediawiki:
server { # This will listen on all interfaces, you can instead choose a specific IP # such as listen x.x.x.x:80; Setting listen 80 default_server; will make # this server block the default one if no other blocks match the request listen 80; listen [::]:80; index index.html index.htm index.php; client_max_body_size 20M; # Here you can set a server name, you can use wildcards such as *.example.com # however remember if you use server_name *.example.com; You'll only match subdomains # to match both subdomains and the main domain use both example.com and *.example.com server_name mywikisite.com; # It is best to place the root of the server block at the server level, and not the location level # any location block path will be relative to this root. root /var/www/mywikisite.com; # It's always good to set logs, note however you cannot turn off the error log # setting error_log off; will simply create a file called 'off'. # access_log /var/log/nginx/mywikisite.access.log; access_log off; error_log /var/log/nginx/mywikisite.error.log; # nedan for fastcgi 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; } #Don't cache if the URL contains a query string if ($query_string != "") { set $no_cache 1; } # Don't cache uris containing the following segments if ($request_uri ~* "/wp-admin/|index.php|/xmlrpc.php|wp-.*.php|/feed/|sitemap(_index)?.xml") { set $skip_cache 1; } # Don't use the cache for logged in users or recent commenters # change something to correct cookie for your mediawiki if ($http_cookie ~* "something_ad_UserID") { set $skip_cache 1; } # slut for fastcgi # Om man har mediawiki i en underkatalog location / { try_files $uri $uri/ /index.php; } location ^~ /mediawiki/maintenance/ { return 403; } location /w { try_files $uri $uri/ /mediawiki/index.php?$query_string; } location ~* ^/w/Fil:(.*\.(png|jpg|jpeg|gif|ico))$ { rewrite ^/w/Fil:(.*\.(png|jpg|jpeg|gif|ico))$ /mediawiki/index.php?title=File:$1 last; } location ~* ^/w/MediaWiki:(.*\.(css))$ { rewrite ^/w/MediaWiki:(.*\.(css))$ /mediawiki/index.php?title=MediaWiki:$1 last; } location ~ \.php$ { include fastcgi_conf; #for fastcgi cache nedan fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache PHPCACHE; fastcgi_cache_valid 60m; fastcgi_cache_valid 200 301 302 304 60m; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; fastcgi_cache_use_stale updating error timeout invalid_header http_500; fastcgi_cache_revalidate on; #nedan for kunna rensa sidor ur cache med scriptet tabortfiler add_header X-Cached $upstream_cache_status; fastcgi_cache_bypass $http_cache_purge; add_header X-Frame-Options SAMEORIGIN; } include drop.conf; include static.conf; }