Skip to content

Commit

Permalink
feat: configure nginx to enable https
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessandroMiola committed Apr 1, 2024
1 parent 0d49229 commit 28d5f43
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__
.ruff_cache
.env
db-data/
certs/
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Settings(BaseSettings):
POSTGRES_SERVER: str = "localhost"
POSTGRES_PORT: int = 5432
POSTGRES_DB: str
NGINX_PORT: int = 443

@property
def database_url(self) -> str:
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- "./db-data/:/var/lib/postgresql/data/"

nginx:
image: nginx:latest
ports:
- "${NGINX_PORT}:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./certs:/etc/nginx/certs
19 changes: 19 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events {}

http {
server {
listen 443 ssl;
server_name localhost;

ssl_certificate /etc/nginx/certs/cert.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
}

0 comments on commit 28d5f43

Please sign in to comment.