server {
  listen 81;
  server_name  www.photonicat.com;
  rewrite ^ http://photonicat.com$request_uri? permanent;
}

server {
  server_name photonicat.com;
  listen 81;
  access_log  /data/novotech-docker/log/nginx-access.log;
  error_log  /data/novotech-docker/log/nginx-error.log;

  location /nginx_status {
    return 200 "ok";
  }

  location /assets/ {
    root /var/www/photonicat;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    access_log off;
    gzip_static  on;
    add_header Cache-Control public;
    add_header Access-Control-Allow-Origin *;
    expires 365d;
  }

  location ~ ^/skins {
            root /www/photonicat-wiki;
        }

        location ~ ^/resources {
            root /www/photonicat-wiki;
        }

        location ~ ^/mw-config {
            root /www/photonicat-wiki;

        location ~ \.php  {
            root /www/photonicat-wiki;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/run/php/php8.1-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /www/photonicat-wiki$fastcgi_script_name;
        }
}

        location ~ ^/wiki$ {
            return 301 $scheme://photonicat.com/wiki/;
        }

        location ~ ^/wiki/ {
            root /www/photonicat-wiki;
            index index.php index.html index.htm;
            if (!-e $request_filename) {
                rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
            }
            if ($uri ~* "\.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$") {
                expires max;
                break;
            }
        }

        location ~ ^/images {
            root /www/photonicat-wiki;
        }

        location ~* \.php$ {
            root /www/photonicat-wiki;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/run/php/php8.1-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /www/photonicat-wiki$fastcgi_script_name;
        }


  # DO NOT CHANGE THIS
  location / {
    proxy_pass http://127.0.0.1:7000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
