Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx Reverse Proxy for Canto-API #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added certs/origin-key.pem
Empty file.
Empty file added certs/origin.pem
Empty file.
16 changes: 14 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@ services:
restart: unless-stopped
build:
context: .
ports:
- "3000:3000"
expose:
- "3000" # Internal port exposed to Nginx
env_file:
- .env

nginx:
image: nginx:latest
restart: unless-stopped
ports:
- "80:80" # HTTP
- "443:443" # HTTPS
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf # Nginx configuration file
- ./certs:/etc/ssl/certs # SSL certificates folder
depends_on:
- canto-api

volumes:
redis-data:
redis-conf:
40 changes: 40 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# nginx.conf

events {}

http {
# HTTP server to redirect all traffic to HTTPS
server {
listen 80;
server_name canto-api.neobase.one;

# Redirect all HTTP requests to HTTPS
location / {
return 301 https://$host$request_uri;
}
}

# HTTPS server to handle SSL traffic
server {
listen 443 ssl;
server_name canto-api.neobase.one;

# SSL certificate and key for Cloudflare Origin Certificate
ssl_certificate /etc/ssl/certs/origin.pem;
ssl_certificate_key /etc/ssl/certs/origin-key.pem;

# SSL settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305';

# Proxy settings to forward requests to the canto-api service
location / {
proxy_pass http://canto-api:3000;
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 $scheme;
}
}
}