Issue
I'm developing a docker project with nginx
and django
services. I've django.conf.template
parameterised to pass environment variables dynamically depends on environment.
django.conf:
upstream django_app {
server ${DJANGO_PRIVATE_IP}:${DJANGO_PORT};
}
server {
listen 80;
listen 443 ssl;
listen [::]:443 ssl;
server_name ${NGINX_SERVER_NAME};
ssl_certificate /etc/nginx/certs/elitecars_cert.pem;
ssl_certificate_key /etc/nginx/certs/elitecars_privkey.pem;
access_log /var/log/nginx/nginx.django.access.log;
error_log /var/log/nginx/nginx.django.error.log;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_pass http://django_app;
}
}
The template works well because i can see the env vars values with more /etc/nginx/conf.d/sites-available/django.conf
command
upstream django_app {
server django:8000;
}
server {
listen 80;
listen 443 ssl;
listen [::]:443 ssl;
server_name 0.0.0.0 127.0.0.1 localhost;
...
But when I tried to access through the browser but doesn't work.
Any idea? Anybody could help me please?
Solution
On local and Mac I need to add host.docker.internal IP to /etc/hosts for nginx config file like this:
127.0.0.1 localhost
172.17.0.1 localhost
...
And solve the problem.
Answered By - Alberto Sanmartin Martinez
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.