You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nginx.conf 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. daemon off;
  2. user www-data www-data;
  3. events {
  4. worker_connections 1024;
  5. }
  6. http {
  7. include mime.types;
  8. sendfile on;
  9. tcp_nopush on;
  10. client_max_body_size 100M;
  11. server {
  12. listen 80;
  13. root /application;
  14. index index.php index.html index.htm;
  15. server_name glitchcity.info www.glitchcity.info;
  16. location / {
  17. try_files $uri $uri/ /index.html;
  18. }
  19. error_page 404 /application/errors/404.html;
  20. error_page 500 502 503 504 /application/errors/50x.html;
  21. location = /50x.html {
  22. root /usr/share/nginx/www;
  23. }
  24. location = / {
  25. return 302 $scheme://$host/wiki/;
  26. }
  27. location = /wiki {
  28. return 302 $scheme://$host/wiki/;
  29. }
  30. location = /wiki/index.php {
  31. return 302 $scheme://$host/wiki/;
  32. }
  33. location ~ ^\/wiki/index.php/(.*)$ {
  34. return 302 $scheme://$host/wiki/$1;
  35. }
  36. location ~ ^\/wiki/.*$ {
  37. rewrite ^/wiki/(.*)$ /w/index.php?title=$1 last;
  38. }
  39. location ~ \.php$ {
  40. try_files $uri =404;
  41. fastcgi_pass unix:/var/run/php5-fpm.sock;
  42. fastcgi_index index.php;
  43. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  44. include fastcgi_params;
  45. # https://stackoverflow.com/a/36451158
  46. set $realip $remote_addr;
  47. if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
  48. set $realip $1;
  49. }
  50. fastcgi_param REMOTE_ADDR $realip;
  51. }
  52. }
  53. server {
  54. listen 80;
  55. root /application/forums;
  56. index index.php index.html index.htm;
  57. server_name forums.glitchcity.info;
  58. location / {
  59. try_files $uri $uri/ /index.html;
  60. }
  61. location ~ ^\/index.php/topic,(.*)$ {
  62. return 302 $scheme://$host/index.php?topic=$1;
  63. }
  64. error_page 404 /application/errors/404.html;
  65. error_page 500 502 503 504 /application/errors/50x.html;
  66. location = /50x.html {
  67. root /usr/share/nginx/www;
  68. }
  69. location ~ \.php$ {
  70. try_files $uri =404;
  71. fastcgi_pass unix:/var/run/php5-fpm.sock;
  72. fastcgi_index index.php;
  73. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  74. include fastcgi_params;
  75. set $realip $remote_addr;
  76. if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
  77. set $realip $1;
  78. }
  79. fastcgi_param REMOTE_ADDR $realip;
  80. }
  81. }
  82. }