I am spinning up a dev environment for an application using docker/docker-compose. I am attempting to set up the app to accept HTTPS protocol (for dev a self-signed cert using openssl is sufficient) but am having issues.
My docker-compose
file (note I am mounting volumes for the certs as well as the nginx.conf file shared below):
services:
nginx:
image: nginx:latest
container_name: webserver
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- /homes/edmisml/nginx_docker_vol/nginx.conf:/etc/nginx/nginx.conf
- /etc/ssl:/ssl/
myservice:
build: ./erschatbot_frontend
restart: unless-stopped
expose:
- 8080
My very simple nginx.conf to allow HTTPS so far:
http {
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /ssl/private/nginx-selfsigned.key;
access_log /var/log/nginx/data-access.log combined;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Host $host;
}
}
}
When I spin up the containers using docker-compose I get the following error
webserver | 2021/03/09 14:53:27 [emerg] 1#1: unexpected "}" in /etc/nginx/nginx.conf:26
webserver | nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:26
So I assume this is a syntax error but I do not see the particular issue. For reference I am roughly following the guide here.
I am a total nginx noob - can someone help me out?
UPDATE: fixed silly typo at line 25 (missing semi-colon) but am still receiving errors when visting the https:<url>
. Error:
webserver | 2021/03/09 15:31:44 [error] 32#32: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 10.75.226.54, server: example.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "example.com"