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