ClocxHD
Lt. Junior Grade
- Registriert
- Aug. 2014
- Beiträge
- 376
Hallo,
ich möchte die Caching-Funktion von Nginx verwenden.
Allerdings funktioniert meine Konfiguration nicht.
Bekomme beim Neustart von Nginx folgende Meldung:
Nginx.conf:
vHost:
Woran liegt das?
LG,
ClocxHD
ich möchte die Caching-Funktion von Nginx verwenden.
Allerdings funktioniert meine Konfiguration nicht.
Bekomme beim Neustart von Nginx folgende Meldung:
Code:
nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/nginx.conf:38
nginx: [emerg] the size 10485760 of shared memory zone "microcache" conflicts with already declared size 0 in /etc/nginx/nginx.conf:41
nginx: configuration file /etc/nginx/nginx.conf test failed
Nginx.conf:
Code:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server_tokens off;
include /etc/nginx/mime.types;
include /etc/nginx/sites-enabled/*;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css text/xml application/x-javascript application/xml application/xml+rss text/javascript;
gzip_vary on;
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:10m max_size=1000m inactive=60m;
include /etc/nginx/conf.d/*.conf;
}
vHost:
Code:
server {
listen 80;
server_name fabian-thielen.de;
#server_name "~^(?!www\.).*" ;
return 301 $scheme://www.$host$request_uri;
}
server {
server_tokens off;
server_name www.fabian-thielen.de;
listen 80;
location / {
root /var/sites/Foundation;
index index.html index.php;
}
location ~* \.php$ {
root /var/sites/Foundation;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#Cache start
# Setup var defaults
set $no_cache "";
# If non GET/HEAD, don't cache & mark user as uncacheable for 1 second via cookie
if ($request_method !~ ^(GET|HEAD)$) {
set $no_cache "1";
}
# Drop no cache cookie if need be
# (for some reason, add_header fails if included in prior if-block)
if ($no_cache = "1") {
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
add_header X-Microcachable "0";
}
# Bypass cache if no-cache cookie is set
if ($http_cookie ~* "_mcnc") {
set $no_cache "1";
}
# Bypass cache if flag is set
fastcgi_no_cache $no_cache;
fastcgi_cache_bypass $no_cache;
fastcgi_cache microcache;
fastcgi_cache_key $scheme$host$request_uri$request_method;
fastcgi_cache_valid 200 301 302 10m;
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
#Cache ende
}
}
Woran liegt das?
LG,
ClocxHD