HTML
<a href="https://instagram.com/" onclick="$(this).attr('href', 'https://www.naver.com')">
onclick 시 href 내용이 https://www.naver.com으로 변경됩니다.
포트 기반 가상 호스팅
vim /etc/nginx/nginx.conf
위와 같이 입력하고 /etc/nginx/conf.d/*.conf를 포함합니다.
확인하다
vim /etc/nginx/conf.d/vhost.conf
위와 같이 vhost.conf 파일을 생성합니다(이름은 관례에 따름).
server {
listen 8081; #listen 80 은 생략 가능
root /web/site1;
}
위의 내용을 작성하고 :wq!
mkdir -p /web/site1 => 위에서 만든 루트 폴더 생성
에코 “
안녕하세요 사이트1
” > /web/site1/index.html => index.html 콘텐츠 입력
systemctl reload nginx (또는 systemctl restart nginx) => 새로 입력한 설정 파일 반영
확인하다
– 컬 192.168.~ :8081
– 크롬에서 192.168~ :8081
아래와 같이 vhost.conf 파일 내용을 변경합니다.
server {
server_name site1.com;
root /web/site1;
}
vim /etc/호스트
127.0.0.1 site1.com
위와 같이 도메인 처리
systemctl nginx 다시 로드
확인하다
– 컬 site1.com
– 크롬에서 http://site1.com
포트 8081에서 이미지 node_hello_1 실행
docker run \
--name=node \
-p 8081:8080 \
--rm \
-d \
node_hello_1
다음 내용을 vim /etc/nginx/conf.d/vhost.conf에 추가합니다.
server {
server_name site2.com;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
systemctl nginx 다시 로드
확인하다
– 컬 site2.com
– 크롬에서 http://site2.com