I'm trying to use PostgREST API to deal with some queries in a PostgreSQL server, but the API doesn't accept HTTPS request as stated in the API documentation:
PostgREST aims to do one thing well: add an HTTP interface to a PostgreSQL database. To keep the code small and focused we do not implement HTTPS. Use a reverse proxy such as NGINX to add this, here’s how.
Our Nginx server is able to deal with HTTPS requests, but I was unable to find a Nginx configuration example that can proxy those HTTPS requests and pass them to PostgREST API as an HTTP request in order to get the JSON file from the above mentioned API.
Here's what I have tried so far:
server {
listen 443 ssl http2;
location = /api {
return 301 http://$host/$request_uri;
}
}
Any help would be amazing!
There's a minimal example in the docs on how to use PostgREST with Nginx in the Hardening PostgREST section. You can adapt it to HTTPS by adding that location section to the server configured for HTTPS, like this:
For clarity, the comments with
#...
reference any other code you may already have in your configuration.