server { listen 80 ; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; ssl_certificate /etc/nginx/cert/img.crt; ssl_certificate_key /etc/nginx/cert/img.key; root /var/www/html/chevereto; index index.html index.htm index.nginx-debian.html; client_max_body_size 50M; server_name img.zeekling.cn; if ( $scheme = http ){ return 301 https://$server_name$request_uri; } location / { add_header Strict-Transport-Security "max-age=31536000"; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php) { rewrite (.*) $1/index.php; } if (!-f $request_filename) { rewrite (.*) /index.php; } try_files $uri $uri/ /api.php; } location ~ .(jpg|png|gif|css|js|pdf|scss|ico|jpeg|bmp|flv|mp4|mp3|swf|wma|wmv|asf|mmf|zip|rar|gz|woff2|woff|ttf)$ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_cache cache_one; proxy_cache_valid 200 302 30d; proxy_cache_valid 301 30d; proxy_cache_valid any 30d; expires 30d; proxy_redirect off; add_header wall "Stay simple, stay naive."; } location /ads.txt { autoindex on; } location /shenma-site-verification.txt { autoindex on; } location /admin { add_header Strict-Transport-Security "max-age=31536000"; try_files $uri /admin/index.php?$args; } location ~ \.php$ { add_header Strict-Transport-Security "max-age=31536000"; include snippets/fastcgi-php.conf; fastcgi_split_path_info ^(.+\.php)(/.+)$; #fastcgi_index index.php; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; include fastcgi_params; } }