How to serve nginx static file with docker

Asked 2 years ago, Updated 2 years ago, 46 views

I'm working on a personal project using Docker.

You want to create a project with https by getting an ssl certificate and setting a password.

nginx added and proceeded with these settings.

ssl                  on;
ssl_certificate      /etc/pki/tls/certs/me/cert_chain.crt;
ssl_certificate_key  /etc/pki/tls/certs/me/my.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers   on;

However, whenever the docker starts, nginx asks for ssl passphrase and closes the container without being created (permission denied error).)

To solve this problem, we found 3 ways.

I thought that method 1 and 2 would be somewhat vulnerable to security, so I tried to solve it through method 3. However, there was a problem with how to serve static files inside the docker container nginx outside the container, so I thought it was difficult to proceed with method 3.

All three of the above methods are difficult, so I would like to ask for your help if there are people who have solved the problem in other ways.

Thank you.

nginx docker

2022-09-21 20:29

1 Answers

It's a self-answer.

I solved it by forwarding from host nginx to nginx inside the docker using proxy_pass.


2022-09-21 20:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.