Last active
February 14, 2023 21:53
-
-
Save bashkirtsevich/3617ec4b5702294e01a3c6dd8d3c87ab to your computer and use it in GitHub Desktop.
Self signed ssl nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
nginx: | |
image: nginx:alpine | |
command: > | |
sh -c " | |
apk add openssl && | |
mkdir -p /var/www/backend/certs/ && | |
cd /var/www/backend/certs/ && | |
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -subj \"/C=/ST=/L=/O=/CN=\" -keyout default.key -out default.crt && | |
nginx -g \"daemon off;\"" | |
volumes: | |
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro | |
restart: unless-stopped | |
ports: | |
- 443:443 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream bar { | |
server somewhere | |
} | |
server { | |
listen 443 ssl http2; | |
ssl_certificate /var/www/backend/certs/default.crt; | |
ssl_certificate_key /var/www/backend/certs/default.key; | |
location /foo/ { | |
proxy_pass http://bar/; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment