Skip to content

Commit

Permalink
Added ssl support
Browse files Browse the repository at this point in the history
  • Loading branch information
5enox committed Jul 10, 2024
1 parent 31b876c commit 9c1527a
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Dockerfile
FROM nginx:alpine

# Copy the Nginx config file into the container
COPY nginx.conf /etc/nginx/nginx.conf

# Copy your application files if needed
# COPY . /usr/share/nginx/html
# Copy your SSL certificate and private key
COPY cert/server.csr /etc/ssl/certs/server.crt
COPY cert/server.key /etc/ssl/private/server.key

# Expose port 80
EXPOSE 80
# Expose port 80 and 443
EXPOSE 80 443

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
29 changes: 29 additions & 0 deletions cert/server.csr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-----BEGIN CERTIFICATE-----
MIIE9jCCA96gAwIBAgISBNsaeMzAsBFduiuToR40ZQ/VMA0GCSqGSIb3DQEBCwUA
MDMxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQwwCgYDVQQD
EwNSMTEwHhcNMjQwNzEwMTA1MjE1WhcNMjQxMDA4MTA1MjE0WjAXMRUwEwYDVQQD
Ewxzb3Vxem9uZS54eXowggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+
/RDz2yaeHLdwgj48anZVx7WvL3CciDVgI+URan+wBUl1NXGvN2QgnRyy0ir6JSTu
+yZ0weVKwdX50adbNN4Z8bj5ndhOEqev1SKauUD66P5RL1JwnhzdmVqAB1S3rvhQ
p8V8p3Mb5stNp+oIupxTDMa7zWhkrdB3bc/J6VthE9LWbxmS5YKiPB5BidPC4q2g
Si2eBTKceJiCo+HQMXEBJR7HEY26QzUOPPxnzCi2D0ijQDpiFN32o+vol878t2zF
GfwgTVBj116srDbXHfJRMyZC/4bpIpgM0ssAlJZlqjMCI+UciYv2Nkfp8x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j0QUQK1T9x19B9ogCbu0wUSNHMptI5t7tYM28h4g
QqiaoJsa4+BW/CJjV3y7CUqHDh3lAv+qMGQ=
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions cert/server.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+/RDz2yaeHLdw
gj48anZVx7WvL3CciDVgI+URan+wBUl1NXGvN2QgnRyy0ir6JSTu+yZ0weVKwdX5
0adbNN4Z8bj5ndhOEqev1SKauUD66P5RL1JwnhzdmVqAB1S3rvhQp8V8p3Mb5stN
p+oIupxTDMa7zWhkrdB3bc/J6VthE9LWbxmS5YKiPB5BidPC4q2gSi2eBTKceJiC
o+HQMXEBJR7HEY26QzUOPPxnzCi2D0ijQDpiFN32o+vol878t2zFGfwgTVBj116s
rDbXHfJRMyZC/4bpIpgM0ssAlJZlqjMCI+UciYv2Nkfp8xh1/Mv3Fa6H98Y8Pva8
ETVcYXPPAgMBAAECggEARO1IBPn+gemTOoOGun8hneupYkQYvCVcPgo2TYbF9lyy
Gh7jnHy9IhgRl2fKIuTs42K4ikK/4a767mH/qCb4URyvyUZyHhsVcZvWFUjubp9P
yTTu573oZQFHbBU5OeFntJQX7djw7gzpKmmDSQswB7kAsB59ongoWDHFX/VcCThh
15pzDJ428C3jztWjR38GjuS+TG8bJqeRa+SztbIly4lpIiyXqPMd6WR1ld0yin2k
/SQH1DlqoYcx1gXaL3RqpQT/ExLa3RKrBy/fbhXJPhkj/7FeDskBPCrvi6uEQ5Rb
/hOvIacaR/Gw1BumNP4I5uY9k+228pYXcgdYFysSQQKBgQD1HM+nCDuFjPJVV8z+
kn/u+cSdYMR+qiqUDYqs2pRTwFf0WWgyR4yN5ECJNRXYvFq8FNeIVAt6wbFqwk5g
iRxwcIUZUKRuqvXnEd3BhwxR7VNcSJx0XPmD4DKuMOUu4valtC2/xn7CRkDep2ja
O5TJ3mmgi1WGUyT9a4M/r01cZwKBgQDHeM7TfO0OdiwVwLjevqtp8h8SlgjQdV7x
2L1A+CXjDBPQo+QLbFzJOzEQVO2NPYuvSqRjV8DsztbYompVPXWOehQVghk1ttRN
+orY6X29cSPIJpNp09Kps1satHaPOKlApaLgqBqteD0vWxUxcwhkwRjDBUzim5fa
JDDai+yMWQKBgQDHSg6Xqzzh3/BkbUfSMADup4sxvizlI6wMxlnbIrj4w2l/1XW/
c6cW8t9573x8xOAtDfET+el/fJ6ow6UAHlrOHN5K7+NRy5S1tDQOFqRwtDpTzQHQ
JowEqjPqpvygO474uV99DoGfqYkyvwCkd08JNtnA26jE1zM7DMAg9oI6vwKBgFCx
fnnvv7Zp98uU+zSgzZc+a3OJXmd2E8Kie20c9baz3BA7PLWiUKbXWzHQKYlJrIht
GbNWfKVPx3o7uehhxHyuxhEtYCVqoNgq0qCNVGCetGrzsA7PshkUhXZ4Kr4lndKZ
LxrS5nfmfFn77sbiUjLwKqQ6MLA7YWLN4TWIBVmBAoGBAKy+4Rgj8Rpfinu8YhEC
T/NFQxx7MR7kP3vMqh8su5HQg/hIZ7hxPf0IuPkrBYDXD9DMXamzGDiG8XBx6rpP
EzY0jRiM/LSTyVYDGDSLM9MzDimcyfMS990NPAoPaU2GBriQuIe1a2NZx1fG5g1X
yb4X3coZqK4sz8AiqM4l8mrt
-----END PRIVATE KEY-----
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- "8000:8000"
volumes:
- .:/app
container_name: fastapi

nginx:
build:
Expand All @@ -18,3 +19,4 @@ services:
- "80:80"
depends_on:
- fastapi
container_name: nginx
72 changes: 69 additions & 3 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,85 @@
# nginx.conf
# nginx.conf
events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name 178.128.198.151; # Adjust this based on your domain name
server_name 157.230.29.110; # Adjust this based on your domain name

location / {
proxy_pass http://178.128.198.151:8000/; # Adjust this based on your backend service
proxy_pass http://157.230.29.110:8000/; # Adjust this based on your backend service
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;
}
}
}

































# events {
# worker_connections 1024;
# }

# http {
# server {
# listen 80;
# server_name 157.230.29.110; # Adjust this based on your domain name

# location / {
# return 301 https://$host$request_uri;
# }
# }

# server {
# listen 443 ssl;
# server_name 157.230.29.110; # Adjust this based on your domain name

# ssl_certificate /etc/ssl/certs/server.crt;
# ssl_certificate_key /etc/ssl/private/server.key;

# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5;

# location / {
# proxy_pass http://157.230.29.110:8000/; # Adjust this based on your backend service
# 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;
# }
# }
# }

0 comments on commit 9c1527a

Please sign in to comment.