server {
	listen 0.0.0.0:80;
	listen [::]:80;
	server_name kraut.space www.kraut.space;

	access_log /var/log/nginx/kraut.space_access.log ano;
	error_log /var/log/nginx/kraut.space_error.log;

	include /etc/nginx/letsencrypt.conf;

	error_page 404 =301 https://wiki.kraut.space$request_uri;

	location / {
		return 301 https://$host$request_uri?;
          }

	location /chaostreff {
		return 301 https://kabi.blue/join/krautspace;
	}
	location /lug {
		return 301 https://kabi.blue/join/krautspace;
	}
	location /plenum {
		return 301 https://kabi.blue/join/krautspace;
	}
	location /btw {
		return 301 https://auth.kabi.tk/index.php/apps/bbb/b/d8Er44TQYC9BJYmp;
	}
	location /nocovid {
		return 301 https://wiki.kraut.space/blog:content:vortrag_von_viola_priesemann;
	}
	location /brettspielerei {
		return 301 https://wiki.kraut.space/hswiki:veranstaltungen:regelmaessige:brettspielerei;
	}
	location /gamingamfreitag {
		return 301 https://wiki.kraut.space/hswiki:veranstaltungen:regelmaessige:gaming;
	}
	location /kinderbasteln {
		return 301 https://wiki.kraut.space/hswiki:veranstaltungen:regelmaessige:kinderbasteln;
	}
	location /iran {
		return 301 https://wiki.kraut.space/blog:content:about_the_current_situation_in_iran_-_report_and_insight_by_locals_and_q_a_live_from_tehran;
	}
}

server {
	listen 0.0.0.0:443 ssl http2;
	listen [::]:443 ssl http2;
        ssl_certificate /var/lib/dehydrated/certs/kraut.space/fullchain.pem;
        ssl_certificate_key /var/lib/dehydrated/certs/kraut.space/privkey.pem;
        server_name kraut.space www.kraut.space;

        access_log /var/log/nginx/kraut.space_access.log ano;
        error_log /var/log/nginx/kraut.space_error.log;

	add_header Strict-Transport-Security max-age=15768000; # six months

	include /etc/nginx/letsencrypt.conf;

	if ($host = www.kraut.space) {
	    return 301 https://wiki.kraut.space$request_uri;
	}

	root /var/www/kraut.space/public/;

	# falls es mal (global) an sein sollte
	autoindex off;
	index index.php;
	client_max_body_size 15M;
	client_body_buffer_size 128k;

	location = /robots.txt  { log_not_found off; }
	location = /favicon.ico { log_not_found off; }	
	location ~ /\.          { deny all; }
	location ~ ~$           { deny all; }

	error_page 404 =301 http://wiki.kraut.space$request_uri;

	location /chaostreff {
		return 301 https://kabi.blue/join/krautspace;
	}
	location /lug {
		return 301 https://kabi.blue/join/krautspace;
	}
	location /plenum {
		return 301 https://kabi.blue/join/krautspace;
	}
	location /btw {
		return 301 https://auth.kabi.tk/index.php/apps/bbb/b/d8Er44TQYC9BJYmp;
	}
	location /nocovid {
		return 301 https://wiki.kraut.space/blog:content:vortrag_von_viola_priesemann;
	}
	location /brettspielerei {
		return 301 https://wiki.kraut.space/hswiki:veranstaltungen:regelmaessige:brettspielerei;
	}
	location /gamingamfreitag {
		return 301 https://wiki.kraut.space/hswiki:veranstaltungen:regelmaessige:gaming;
	}
	location /kinderbasteln {
		return 301 https://wiki.kraut.space/hswiki:veranstaltungen:regelmaessige:kinderbasteln;
	}
	location /iran {
		return 301 https://wiki.kraut.space/blog:content:about_the_current_situation_in_iran_-_report_and_insight_by_locals_and_q_a_live_from_tehran;
	}

	# führe PHP-Script aus
	location ~ \.php$ {
		include fastcgi_params;
		fastcgi_buffers 16 16k; 
		fastcgi_buffer_size 32k;
		fastcgi_param SCRIPT_FILENAME $request_filename;
		fastcgi_intercept_errors on;
		fastcgi_pass unix:/etc/alternatives/php-fpm.sock;
		# entferne Header "X-Powered-By: PHP/5.4.40-1~dotdeb+wheezy.1"
		fastcgi_hide_header "X-Powered-By";
		fastcgi_read_timeout 120;
	}

        include snippets/xmpp.conf;
        include snippets/chat2.conf;
        include snippets/chat1.conf;
}
