nginx.conf 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. server {
  2. listen 80 default_server;
  3. root /opt/una;
  4. client_max_body_size 200M;
  5. # Compress text responses. HTML is compressed whenever gzip is on; the
  6. # types below add CSS/JS/JSON/SVG. Already-compressed responses (the
  7. # gzip_loader.php bundles, which set Content-Encoding themselves, and
  8. # woff2 fonts) are left untouched by nginx.
  9. gzip on;
  10. gzip_vary on;
  11. gzip_proxied any;
  12. gzip_comp_level 5;
  13. gzip_min_length 256;
  14. gzip_types text/plain text/css text/xml application/javascript text/javascript application/json application/xml image/svg+xml application/manifest+json application/wasm;
  15. location / {
  16. index index.html index.htm index.php;
  17. rewrite "^/page/(.*)$" /page.php?i=$1 last;
  18. rewrite "^/m/(.*)$" /modules/index.php?r=$1 last;
  19. rewrite "^/s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)" /storage.php?o=$1&f=$2 last;
  20. if (!-e $request_filename) {
  21. rewrite ^/(.+)$ /r.php?_q=$1 last;
  22. break;
  23. }
  24. }
  25. # Long-lived caching for real static files. Virtual paths that merely end
  26. # in an asset extension (/s/<obj>/<file>.png served by storage.php, or a
  27. # missing file routed through r.php) are not files on disk, so try_files
  28. # hands them to @dynamic instead of 404ing.
  29. location ~* \.(?:woff2?|ttf|otf|eot|svg|png|jpe?g|gif|webp|avif|ico|css|js|mjs|map)$ {
  30. try_files $uri @dynamic;
  31. expires 30d;
  32. add_header Cache-Control "public";
  33. access_log off;
  34. }
  35. location @dynamic {
  36. rewrite "^/s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)" /storage.php?o=$1&f=$2 last;
  37. rewrite ^/(.+)$ /r.php?_q=$1 last;
  38. }
  39. index index.php index.html index.htm;
  40. location ~ \.php$ {
  41. fastcgi_pass php:9000;
  42. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  43. include fastcgi_params;
  44. }
  45. }