estoy trabajando con Docker usando nginx proxy reverse
, me encontré con un error que probablemente sea de mi configuración que tengo al levantar contenedores.
Al crear contenedores con subdominios por ejemplo: example.midominio.com, sin certificado ejecuta bien y levanta el contenedor al igual que puedo visualizar el html en el navegador, pero al levantar un contenedor con un dominio: midominio.com me marca un error en el navegador de 502.
Esto es lo que ejecutó para levantar un subdominio:
docker run -d --name example.midominio.com --expose 80 --net nginx-proxy --link mariadb:mariadb -v /home/ec2-user/userecommerce/$1/html:/var/www/html -e VIRTUAL_HOST=example.midominio.com -e VIRTUAL_PROTO=http -e VIRTUAL_PORT=80 -e HTTPS_METHOD=noredirect ecommercefya:v3
Esto es lo que ejecutó para levantar un dominio:
docker run -d --name midominio.com --expose 80 --expose 443 --net nginx-proxy --link mariadb:mariadb -v /home/ec2-user/userecommerce/midominio.com/html:/var/www/html -e VIRTUAL_HOST=midominio.com -e VIRTUAL_PROTO=http -e VIRTUAL_PORT=80 -e VIRTUAL_PROTO=https -e VIRTUAL_PORT=443 -e HTTPS_METHOD=noredirect ecommercefya:v3
Este es el comando para levantar el nginx-proxy:
docker run -d --name nginx-proxy --net nginx-proxy -p 80:80 -p 443:443 -e HTTPS_METHOD=noredirect -e HSTS=off -v /home/ec2-user/ssl:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
Al ejecutar docker logs en el nginx-proxy:
2019/12/16 18:55:15 [error] 545#545: *1837 connect() failed (111: Connection refused) while connecting to upstream, client: 200.14.138.67, server: minubeya.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.24.0.4:443/favicon.ico", host: "minubeya.com", referrer: "http://example.midominio.com"
Y en mi contenedor con certificado ssl y dominio:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.24.0.4. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.24.0.4. Set the 'ServerName' directive globally to suppress this message
[Mon Dec 16 16:42:37.897214 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.2.24 configured -- resuming normal operations
[Mon Dec 16 16:42:37.897270 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
Este es el contenido de mi default.conf:
# minubeya.com
upstream example.midominio.com {
## Can be connected with "nginx-proxy" network
# minubeya.com
server 172.24.0.4:443;
}
server {
server_name example.midominio.com;
listen 443 ssl http2 ;
access_log /var/log/nginx/access.log vhost;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/minubeya.com.crt;
ssl_certificate_key /etc/nginx/certs/minubeya.com.key;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/nginx/certs/minubeya.com.chain.pem;
location / {
proxy_pass example.midominio.com;
}
}
server {
server_name example.midominio.com;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass example.midominio.com;
}
}
Este es el contenido de mi nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
daemon off;