
동일한 도커 브리지의 django 설정에 역방향 프록시를 적용하는 가상 호스트로 실행되는 nginx 도커가 있습니다(작동합니다). nginx 자체에서 정적 HTML 콘텐츠를 제공하는 두 번째 가상 호스트를 추가하려고 합니다. 웹에서 예제를 따르려고 노력하고 있지만 제대로 작동하지 못했습니다. 누군가가 내가 뭘 잘못하고 있는지 알아차릴 수 있기를 바랍니다.
아래 파일에서는 익명성을 위해 DNS 이름을 변경했습니다. abcde.wxyz.org와 abcd.defgh.org는 모두 동일한 IP로 확인되며 이름 확인은 제대로 작동합니다. (a) 액세스https://abcd.defgh.org/(즉, 프록시)는 잘 작동합니다. (b) 접근http://abcde.wxyz.org/(정적 웹페이지) ERR_CONNECTION_REFUSED가 표시됩니다. (c) 액세스 중https://abcde.wxyz.org/(a)에 이르게 하는데, 이런 일도 일어나서는 안 됩니다.
내가 도대체 뭘 잘못하고있는 겁니까?
내 /etc/nginx/nginx.conf 파일은 다음과 같습니다.
user nginx;
worker_processes 1;
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;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/ 디렉토리에는 다음과 같은 파일('django.conf'라고 함)이 하나 있습니다.
server {
listen 80;
server_name abcd.defgh.org;
access_log /var/www/logs/abcd.defgh.org.log;
error_log /var/www/logs/abcd.defgh.org.log error;
root /var/www/abcd.defgh.org/public_html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
server {
listen 80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name abcde.wxyz.org;
ssl_certificate /etc/ssl/certs/localhost.crt;
ssl_certificate_key /etc/ssl/private/localhost.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
location / {
proxy_pass http://web:8000;
}
}
'web'은 docker name 서비스에 의해 확인되어 작동합니다.
추가 문제 해결을 위해 nginx docker에서 액세스 로그나 오류 로그를 얻을 수 없는 것 같습니다.
답변1
허위 경보. 도커 환경 문제로 확인되었습니다. Docker는 포트 80이 아닌 포트 443만 전달되도록 설정되었습니다.