nginx_example.conf 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name example.mydomain.com;
  5. return 301 https://example.mydomain.com$request_uri;
  6. }
  7. server {
  8. listen 443 ssl http2;
  9. listen [::]:443 ssl http2;
  10. server_name example.mydomain.com;
  11. ssl_certificate /etc/letsencrypt/live/example.mydomain.com/fullchain.pem;
  12. ssl_certificate_key /etc/letsencrypt/live/example.mydomain.com/privkey.pem;
  13. include /etc/nginx/tls-profile.conf;
  14. ssl_prefer_server_ciphers on;
  15. root "/www/example";
  16. index index.html index.htm index.cgi index.php index.php5 ;
  17. #error_page 400 401 402 403 404 405 406 407 408 500 501 502 503 504 505 @error_page;
  18. error_page 400 402 403 404 405 406 407 408 500 501 502 503 504 505 @error_page;
  19. error_page 401 /errorpages/401.htm;
  20. location @error_page {
  21. root /www/error_page;
  22. rewrite ^ /$status.html break;
  23. }
  24. gzip on;
  25. gzip_disable "msie6";
  26. gzip_vary on;
  27. gzip_proxied expired no-cache no-store private auth;
  28. #compression level
  29. gzip_comp_level 6;
  30. gzip_min_length 1000;
  31. gzip_buffers 16 8k;
  32. gzip_http_version 1.1;
  33. # files to gzip
  34. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
  35. location / {
  36. auth_basic "Protected";
  37. auth_basic_user_file /www/passwd/.htpasswd;
  38. try_files $uri $uri/ =404;
  39. }
  40. location /errorpages {
  41. auth_basic off;
  42. try_files $uri $uri/ =404;
  43. }
  44. location ~ \.css$ {
  45. auth_basic off;
  46. try_files $uri $uri/ =404;
  47. }
  48. location ~ \.png$ {
  49. auth_basic off;
  50. try_files $uri $uri/ =404;
  51. }
  52. location ~ \.ico$ {
  53. auth_basic off;
  54. try_files $uri $uri/ =404;
  55. }
  56. location /htadmin {
  57. auth_basic off;
  58. try_files $uri $uri/ =404;
  59. }
  60. location /htadmin/config {
  61. deny all;
  62. return 404;
  63. }
  64. location /htadmin/includes {
  65. deny all;
  66. return 404;
  67. }
  68. location /htadmin/tools {
  69. deny all;
  70. return 404;
  71. }
  72. location ~ \.php$ {
  73. try_files $uri =404;
  74. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  75. fastcgi_pass php:9000;
  76. fastcgi_index index.php;
  77. include fastcgi_params;
  78. fastcgi_param HOST "example.mydomain.com";
  79. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  80. fastcgi_param PATH_INFO $fastcgi_path_info;
  81. }
  82. }