Skip to content

Commit

Permalink
add certbot + nginx.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil-sagwekar2652 committed Jan 10, 2024
1 parent a8250b6 commit ee1c989
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
15 changes: 13 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ services:
nginx:
depends_on:
- flask_blog
build:
nginx
- certbot
image: nginx:stable
restart: always
links:
- flask_blog
ports:
- 80:80
- 443:443
volumes:
- ./nginx/:/etc/nginx/conf.d/:ro
- ./certbot/www:/var/www/certbot/:ro

certbot:
image: certbot/certbot:latest
volumes :
- ./certbot/www:/var/www/certbot/:rw
- ./certbot/conf/:/etc/letsencrypt/:rw

db:
image: postgres:12-bullseye
Expand Down
4 changes: 0 additions & 4 deletions nginx/Dockerfile

This file was deleted.

24 changes: 22 additions & 2 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,34 @@ upstream flask_blog {
}

server {

listen 80;
listen [::]:80;

server_name blog.sahilsagwekar.co;
server_tokens off;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

location / {
return 301 https://blog.sahilsagwekar.co$request_uri;
}
}

server {
listen 443 default_server ssl http2;
listen [::]:443 ssl http2;

server_name blog.sahilsagwekar.co;

ssl_certificate /etc/nginx/ssl/live/blog.sahilsagwekar.co/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/blog.sahilsagwekar.co/privkey.pem;

location / {
proxy_pass http://flask_blog;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}

}

0 comments on commit ee1c989

Please sign in to comment.