laravel_varnish.conf.example 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name www.laravel.test;
  5. rewrite ^(.*) https://laravel.test$1/ permanent;
  6. }
  7. server {
  8. listen 80;
  9. listen [::]:80;
  10. server_name laravel.test;
  11. rewrite ^(.*) https://laravel.test$1/ permanent;
  12. }
  13. server {
  14. listen 443 ssl ;
  15. listen [::]:443 ssl;
  16. ssl_certificate /etc/nginx/ssl/laravel.test.crt;
  17. ssl_certificate_key /etc/nginx/ssl/laravel.test.key;
  18. server_name www.laravel.test;
  19. rewrite ^(.*) https://laravel.test$1/ permanent;
  20. }
  21. server {
  22. server_name laravel.test;
  23. # For https
  24. listen 443 ssl ;
  25. listen [::]:443 ssl;
  26. ssl_certificate /etc/nginx/ssl/laravel.test.crt;
  27. ssl_certificate_key /etc/nginx/ssl/laravel.test.key;
  28. port_in_redirect off;
  29. add_header Strict-Transport-Security "max-age=31536000";
  30. add_header X-Content-Type-Options nosniff;
  31. location / {
  32. proxy_pass http://proxy:6081;
  33. proxy_set_header Host $http_host;
  34. proxy_set_header X-Forwarded-Host $http_host;
  35. proxy_set_header X-Real-IP $remote_addr;
  36. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  37. proxy_set_header X-Forwarded-Proto https;
  38. proxy_set_header HTTPS "on";
  39. proxy_redirect off;
  40. }
  41. }
  42. server {
  43. server_name laravel.test;
  44. listen 81;
  45. listen [::]:81;
  46. root /var/www/laravel.test/www;
  47. index index.php index.html index.htm;
  48. location / {
  49. try_files $uri $uri/ /index.php$is_args$args;
  50. }
  51. location ~ \.php$ {
  52. fastcgi_max_temp_file_size 4m;
  53. fastcgi_pass php-upstream;
  54. # Additional configs
  55. fastcgi_pass_header Set-Cookie;
  56. fastcgi_pass_header Cookie;
  57. fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
  58. try_files $uri /index.php =404;
  59. fastcgi_index index.php;
  60. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  61. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  62. fastcgi_param PATH_INFO $fastcgi_path_info;
  63. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  64. fastcgi_param HTTPS on;
  65. fastcgi_buffers 16 16k;
  66. fastcgi_buffer_size 32k;
  67. fastcgi_intercept_errors on;
  68. #fixes timeouts
  69. fastcgi_read_timeout 600;
  70. include fastcgi_params;
  71. }
  72. # Caching
  73. location ~* \.(ico|jpg|webp|jpeg|gif|css|png|js|ico|bmp|zip|woff)$ {
  74. access_log off;
  75. log_not_found off;
  76. add_header Pragma public;
  77. add_header Cache-Control "public";
  78. expires 14d;
  79. }
  80. location ~* \.(php|html)$ {
  81. access_log on;
  82. log_not_found on;
  83. add_header Pragma public;
  84. add_header Cache-Control "public";
  85. expires 14d;
  86. }
  87. location ~ /\.ht {
  88. deny all;
  89. }
  90. }