forked from mattheworres/hootdraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXAMPLE_nginx
79 lines (62 loc) · 2.9 KB
/
EXAMPLE_nginx
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Example NGINX Configuration
# This is an example of what is required in order to get HootDraft to run on NGINX.
# This config also uses PHP-FPM 7.0 so paths may very there.
# Mileage may vary.
#Server block #1: forward any non-HTTPS requests to the third server block.
server {
listen 80 default_server;
listen [::]:80 default_server;
#Change the domain below to the domain name or IP address the site will run off of
server_name example.com;
#We want NGINX to forward to the https version, along with a 301 status to indicate a permanent redirect
#Be sure to change domain below to the correct one, without "www"
return 301 https://example.com$request_uri;
}
#Server block #2: forward any HTTPS or non-HTTPS requests to the "www" subdomain to the third server block
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
#Domain below should have the www subdomain:
server_name www.example.com;
ssl_certificate /etc/nginx/ssl/your_ssl_certificate.crt;
ssl_certificate_key /etc/nginx/ssl/your_ssl_private.key;
#We want NGINX to forward to the non-www HTTPS version, along with a 301 status to indicate a permanent redirect
#Be sure to change domain below to the correct one, without "www"
return 301 https://example.com$request_uri;
}
#Server block #3: serve the Angular app via index.html, Silex API thru /api, files/media as-is
server {
listen 443 ssl http2;
#Change the absolute path below to the base directory that Hoot Draft lives
root /var/www/example.com/current;
index index.html;
#Change the domain below to the domain name or IP address the site will run off of
#NOTE: the "www" subdomain is purposefully left off. In the first server block, we are explicitly
#choosing to forward
server_name example.com;
#Change both paths below to point to both the SSL certificate and the private key you have on the server:
ssl_certificate /etc/nginx/ssl/your_ssl_certificate.crt;
ssl_certificate_key /etc/nginx/ssl/your_ssl_private.key;
location /api/ {
try_files $uri /api/bootstrap.php$is_args$args;
}
#Ensure the path passed to fastcgi_pass below matches up with where php-fpm lives
location ~* \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
}