관리

nginx Server Block(Virtual Host) - Windows

T8.CO.KR 2026. 9. 25. 17:44
한 서버에서 80번 포트로 사이트를 여러개 운영한다.

서버에서 nginx 설치 폴더와 사이트의 웹루트 폴더를 다음과 같다고 가정한다.

-. C:\nginx-1.22.0\conf\nginx.conf 파일

worker_processes 1;

events {

  worker_connections 1024;

}

http {

  include   mime.types;

  default_type application/octet-stream;

  include "C:/nginx-1.22.0/conf/sites-enabled/*.conf";

}

-. C:\nginx-1.22.0\conf\sites-enabled\example.com.conf 파일 *example.com 사이트

server {

      listen      80;

      server_name example.com;

      location / {

          root html;

          index index.html index.htm;

      }

      error_page  500 502 503 504 /50x.html;

      location = /50x.html {

          root html;

      }

}

-. C:\nginx-1.22.0\conf\sites-enabled\example2.com.conf 파일 *example2.com 사이트

server {

      listen      80;

      server_name example2.com;

      location / {

          root html2;

          index index.html index.htm;

      }

      error_page  500 502 503 504 /50x.html;

      location = /50x.html {

          root html2;

      }

}

-. C:\nginx-1.22.0\conf\sites-enabled\example3.com.conf 파일 *example3.com 사이트

server {

      listen      80;

      server_name example3.com;

      location / {

          root html3;

          index index.html index.htm;

      }

      error_page 500 502 503 504 /50x.html;

      location = /50x.html {

          root html3;

      }

}