server {
    listen 80;
    server_name localhost 127.0.0.1 ~^\d+\.\d+\.\d+\.\d+$;
    index index.html index.htm index.php default.html default.htm default.php;
    root /workspace/zhct/zhctproject/store/public;

    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    add_header Content-Security-Policy "manifest-src 'self'";

    location ^~ /aizhct/ {
        proxy_pass http://127.0.0.1/;
        proxy_set_header Host aizhct.local.internal;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location ^~ /raw-files/ {
        alias /workspace/zhct/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        types { }
        default_type text/plain;

        allow 127.0.0.1;
        allow 192.168.0.0/16;
        allow 183.204.240.151;
        deny all;
    }

    location = /__mdview/index.html {
        alias /usr/local/nginx/conf/mdview/index.html;
        default_type text/html;
        charset utf-8;
        add_header Cache-Control "no-store";

        allow 127.0.0.1;
        allow 192.168.0.0/16;
        allow 183.204.240.151;
        deny all;
    }

    location ~* ^/files/.*\.md$ {
        rewrite ^ /__mdview/index.html last;
    }

    location /files/ {
        alias /workspace/zhct/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        types { }
        default_type text/plain;

        allow 127.0.0.1;
        allow 192.168.0.0/16;
        allow 183.204.240.151;
        deny all;
    }

    location /manuals/ {
        alias /workspace/zhct/zhctprompt/operation-manuals/;
        index index.html;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        default_type application/octet-stream;

        allow 127.0.0.1;
        allow 192.168.0.0/16;
        allow 183.204.240.151;
        deny all;
    }

    location = /zhctprompt {
        return 301 /zhctprompt/;
    }

    location ~* ^/zhctprompt/.*\.md$ {
        rewrite ^ /__mdview/index.html last;
    }

    location /zhctprompt/operation-manuals/ {
        alias /workspace/zhct/zhctprompt/operation-manuals/;
        index __disable_index__;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        default_type application/octet-stream;

        allow 127.0.0.1;
        allow 192.168.0.0/16;
        allow 183.204.240.151;
        deny all;
    }

    location /zhctprompt/ {
        alias /workspace/zhct/zhctprompt/;
        index index.html index.htm;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        default_type application/octet-stream;

        allow 127.0.0.1;
        allow 192.168.0.0/16;
        allow 183.204.240.151;
        deny all;
    }

    include rewrite/thinkphp.conf;
    include enable-php.conf;

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires 30d;
    }

    location ~ .*\.(js|css)?$ {
        expires 12h;
    }

    location ~ /.well-known {
        allow all;
    }

    location ~ /\. {
        deny all;
    }

    access_log /workspace/wwwlogs/zhct.local-ip.log main;
    error_log /workspace/wwwlogs/zhct.local-ip.error.log warn;
}
