I am working with Docker using nginx proxy reverse
, I found an error that is probably from my configuration that I have when lifting containers.
When creating containers with subdomains for example: example.mydomain.com, without a certificate it executes well and raises the container just as I can display the html in the browser, but when raising a container with a domain: mydomain.com it marks an error in the 502 browser.
This is what you ran to set up a subdomain:
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
This is what you ran to raise a domain:
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
This is the command to bring up the 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
When running docker logs on the 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.mydomain.com "
And in my container with ssl certificate and domain:
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'
This is the content of my 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;
}
}
This is the content of my 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;