|
| 1 | +fastcgi_cache_path /dev/shm levels=1:2 keys_zone=laravel:100m; |
| 2 | +fastcgi_cache_key "$scheme$request_method$host$request_uri$query_string"; |
| 3 | + |
| 4 | +#server { |
| 5 | +# listen 80; |
| 6 | +# server_name laravel.info; |
| 7 | +# rewrite ^ https://$server_name$request_uri? permanent; |
| 8 | +#} |
| 9 | + |
| 10 | +#server { |
| 11 | +# listen 443; |
| 12 | +# server_name www.laravel.info; |
| 13 | + |
| 14 | + # ssl on; |
| 15 | + # ssl_certificate /etc/ssl/certs/ssl.cert; |
| 16 | + # ssl_certificate_key /etc/ssl/private/ssl.key; |
| 17 | + |
| 18 | +# rewrite ^ https://laravel.info$request_uri? permanent; |
| 19 | +#} |
| 20 | + |
| 21 | +server { |
| 22 | + listen 80 default_server; |
| 23 | + server_name laravel.info; |
| 24 | + |
| 25 | + #ssl on; |
| 26 | + #ssl_certificate /etc/ssl/certs/ssl.cert; |
| 27 | + #ssl_certificate_key /etc/ssl/private/ssl.key; |
| 28 | + |
| 29 | + root /usr/share/nginx/html/; |
| 30 | + index index.php index.html; |
| 31 | + |
| 32 | + client_max_body_size 5M; |
| 33 | + |
| 34 | + # Compression |
| 35 | + |
| 36 | + # Enable Gzip compressed. |
| 37 | + gzip on; |
| 38 | + |
| 39 | + # Enable compression both for HTTP/1.0 and HTTP/1.1. |
| 40 | + gzip_http_version 1.1; |
| 41 | + |
| 42 | + # Compression level (1-9). |
| 43 | + # 5 is a perfect compromise between size and cpu usage, offering about |
| 44 | + # 75% reduction for most ascii files (almost identical to level 9). |
| 45 | + gzip_comp_level 5; |
| 46 | + |
| 47 | + # Don't compress anything that's already small and unlikely to shrink much |
| 48 | + # if at all (the default is 20 bytes, which is bad as that usually leads to |
| 49 | + # larger files after gzipping). |
| 50 | + gzip_min_length 256; |
| 51 | + |
| 52 | + # Compress data even for clients that are connecting to us via proxies, |
| 53 | + # identified by the "Via" header (required for CloudFront). |
| 54 | + gzip_proxied any; |
| 55 | + |
| 56 | + # Tell proxies to cache both the gzipped and regular version of a resource |
| 57 | + # whenever the client's Accept-Encoding capabilities header varies; |
| 58 | + # Avoids the issue where a non-gzip capable client (which is extremely rare |
| 59 | + # today) would display gibberish if their proxy gave them the gzipped version. |
| 60 | + gzip_vary on; |
| 61 | + |
| 62 | + # Compress all output labeled with one of the following MIME-types. |
| 63 | + gzip_types |
| 64 | + application/atom+xml |
| 65 | + application/javascript |
| 66 | + application/json |
| 67 | + application/rss+xml |
| 68 | + application/vnd.ms-fontobject |
| 69 | + application/x-font-ttf |
| 70 | + application/x-web-app-manifest+json |
| 71 | + application/xhtml+xml |
| 72 | + application/xml |
| 73 | + font/opentype |
| 74 | + image/svg+xml |
| 75 | + image/x-icon |
| 76 | + text/css |
| 77 | + text/plain |
| 78 | + text/x-component; |
| 79 | + # text/html is always compressed by HttpGzipModule |
| 80 | + |
| 81 | +# location /api { |
| 82 | +# auth_basic off; |
| 83 | +# try_files $uri $uri/ /index.php?$query_string; |
| 84 | +# } |
| 85 | + |
| 86 | + location / { |
| 87 | +# auth_basic "Restricted access"; |
| 88 | +# auth_basic_user_file /etc/nginx/.htpasswd; |
| 89 | + try_files $uri $uri/ /index.php?$query_string; |
| 90 | + } |
| 91 | + |
| 92 | + location ~ \.php$ { |
| 93 | + root /var/www/html/public; |
| 94 | + fastcgi_cache laravel; |
| 95 | + fastcgi_cache_valid 200 204 1m; |
| 96 | + fastcgi_ignore_headers Cache-Control; |
| 97 | + fastcgi_no_cache $http_authorization $cookie_laravel_session; |
| 98 | + fastcgi_cache_lock on; |
| 99 | + fastcgi_cache_lock_timeout 10s; |
| 100 | + |
| 101 | + add_header X-Proxy-Cache $upstream_cache_status; |
| 102 | + |
| 103 | + fastcgi_pass app:9000; |
| 104 | + fastcgi_index index.php; |
| 105 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 106 | + fastcgi_read_timeout 900s; |
| 107 | + include fastcgi_params; |
| 108 | + } |
| 109 | + |
| 110 | + location ~* \.(jpg|jpeg|png|gif|ico|css|js|eot|ttf|woff|woff2)$ { |
| 111 | + # auth_basic off; |
| 112 | + expires max; |
| 113 | + add_header Cache-Control public; |
| 114 | + add_header Access-Control-Allow-Origin *; |
| 115 | + access_log off; |
| 116 | + try_files $uri $uri/ /index.php?$query_string; |
| 117 | + } |
| 118 | + |
| 119 | + location ~ /\.ht { |
| 120 | + deny all; |
| 121 | + } |
| 122 | +} |
| 123 | + |
0 commit comments