-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx-config-app.sh
62 lines (50 loc) · 2.09 KB
/
nginx-config-app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -----------------------------------------------------------------------------------
# Nginx Configuration File for Laravel Web App.
# Written by Akash Mitra (Twitter @aksmtr)
# Written for Ubuntu 18.04 LTS.
# -----------------------------------------------------------------------------------
# server block for the application
server {
listen 80;
server_name example.com;
root /var/www/app/public;
index index.html index.php;
# we are changing the locations of default log files
access_log /var/www/logs/access.log;
error_log /var/www/logs/error.log;
# other nginx parameters
charset utf-8;
client_max_body_size 25M;
# additional headers to be added
add_header X-Frame-Options "sameorigin";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header X-Cache $upstream_cache_status;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# Nginx Cache Control for Static Files (Browser Cache Control Directives)
# This will instruct browsers to cache the files for 360 days.
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
# Nginx Pass PHP requests to PHP-FPM
# Refer: https://laravel.com/docs/7.x/deployment
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
# Prevent (deny) Access to Hidden Files with Nginx.
# However, LetsEncrypt needs access to the .well-known directory.
location ~ /\.(?!well-known).* {
deny all;
access_log off;
log_not_found off;
}
}