nginx가 호스트 컴퓨터 ( apt-get install
) 에서 실행중인 경우가 아닌 docker nginx의 문제를 발견했습니다 . 내 문제를 재현하는 방법은 다음과 같습니다.
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker run -ti --name agitated_stallman ubuntu:14.04 bash
nc -l 4545
LOLPATH=$HOME/testdocker
echo $LOLPATH
mkdir -p $LOLPATH
cd $LOLPATH
subl mple.conf
.
server {
listen 80;
root /var/www/html;
location /roz {
proxy_pass http://neocontainer:4545;
proxy_set_header Host $host;
}
}
.
docker run --link agitated_stallman:neocontainer -v $LOLPATH/mple.conf:/etc/nginx/sites-available/default -p 12345:80 nginx:1.9
sudo apt-get install curl
curl http://localhost:12345/roz
'nginx'의 오류 응답 :
2016/03/04 19:59:18 [error] 8#8: *3 open() "/usr/share/nginx/html/roz" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /roz HTTP/1.1", host: "localhost:12345"
172.17.0.1 - - [04/Mar/2016:19:59:18 +0000] "GET /roz HTTP/1.1" 404 169 "-" "curl/7.45.0" "-"
sudo apt-get install nginx
sudo subl /etc/nginx/sites-available/default
.
server {
listen 80;
root /var/www/html;
location /roz {
proxy_pass http://localhost:4646;
proxy_set_header Host $host;
}
}
.
sudo service nginx restart
nc -l 4646
sudo apt-get install curl
curl http://localhost:80/roz
'nc'의 SUCCESS 응답 :
GET /roz HTTP/1.0
Host: localhost
Connection: close
User-Agent: curl/7.45.0
Accept: */*
요컨대 : nginx 컨테이너를 -v $LOLPATH/mple.conf:/etc/nginx/conf.d/default.conf
nginx:1.9
도커 이미지는 현재 공식 데비안 저장소가 아닌 nginx 자체 저장소의 nginx 패키지를 사용 합니다. 당신이 검사하는 경우 해당 패키지를 , 당신은 찾을거야 /etc/nginx/nginx.conf
않습니다 include
만에서 /etc/nginx/conf.d/*.conf
, 사전 포함하여 해당 패키지 선박 /etc/nginx/conf.d/default.conf
:
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# other not important stuff
# ...
}
따라서 구성이 전혀 사용되지 않아 open() "/usr/share/nginx/html/roz" failed
오류 를 설명합니다 .
nginx를 호스트에 직접 설치할 때, 다른 메인 설정 파일이있는 공식 데비안 저장소를 사용할 것입니다.이 저장소는 다른 기본 설정 파일을 가지고 있으며 include /etc/nginx/sites-available/*
설정은 실제로 사용됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다