-
Notifications
You must be signed in to change notification settings - Fork 1
NGINX Configuration
Nick Diakopoulos edited this page Mar 30, 2022
·
7 revisions
Assuming you start with a basic NGINX install from the EC2 repositories, the configuration is very simple. Simply place the following directives in the server block of /etc/nginx/nginx.conf:
location = /api { rewrite ^ /api/; }
location /api { try_files $uri @api; }
location @api {
include uwsgi_params;
uwsgi_pass unix:///tmp/api.sock;
}
location / {
try_files $uri $uri/ /index.html;
}and then restart the server with service nginx restart.
In addition these details need to be served from 443 to support https, which is required in order to get Google login to work. Add the block below which the correct paths to the ssl certificate (pem) and certificate_key (key)
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name localhost;
root /var/www;
ssl_certificate "<insert pem>";
ssl_certificate_key "<insert key>";
# # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location = /api { rewrite ^ /api/; }
location /api { try_files $uri @api; }
location @api {
include uwsgi_params;
uwsgi_pass unix:///tmp/api.sock;
}
location / {
try_files $uri $uri/ /index.html;
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}