여러 로컬 사이트가 있고 각 웹 사이트의 다른 호스트를 갖도록 nginx를 구성하고 싶습니다. 사이트 1과 사이트 2 nginx에서 localhost 호스트 이름 변경
그런 다음 각 하나의/etc/nginx를/사이트-가능/내가 만든 2 개 개의 다른 구성 서버의 경우 :/var/www가에서나는이 개 사이트가있다. 나는 내용이 같이있는 파일 사이트 1과 사이트 2가 :
server {
listen 80;
root /var/www/site1;
index index.html index.htm;
server_name localhost;
location/{
try_files $uri $uri/ /index.html;
}
}
및
server {
listen 7777;
root /var/www/site2;
index index.html index.htm;
server_name localhost;
location/{
try_files $uri $uri/ /index.html;
}
}
내가 사이트 2에 대한 사이트 개발을위한 http://localhost:80
및 http://localhost:7777
으로 그들에게 접근
127.0.0.1 localhost site1 site2
내가 http://site1:80
과 http://site2:7777
로 액세스 할 수 있습니다. 하지만 항상 포트 번호에 액세스해야합니다. http://site1
및 http://site2
에 액세스하려고합니다.
해결 방법이 있습니까?
server_name을 site1과 site2로 변경 한 다음 동일한 포트 80을 입력하여 솔루션을 찾았습니다. –