로그인

검색

Server
2011.10.31 21:43

Nginx 가상호스트 설정

조회 수 27860 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄


Virtual Hosts Examples

Two Virtual Hosts, Serving Static Files

http {
  index index.html;
 
  server {
    server_name www.domain1.com;
    access_log logs/domain1.access.log main;
 
    root /var/www/domain1.com/htdocs;
  }
 
  server {
    server_name www.domain2.com;
    access_log  logs/domain2.access.log main;
 
    root /var/www/domain2.com/htdocs;
  }
}

A Default Catchall Virtual Host

http {
  index index.html;
 
  server {
    listen 80 default;
    server_name _;
    access_log logs/default.access.log main;
 
    server_name_in_redirect off;
 
    root  /var/www/default/htdocs;
  }
}

Wildcard Subdomains in a Parent Folder

This is just a really easy way to keep adding new subdomains, or to add new domains automatically when DNS records are pointed at the server. Note that I have included FCGI here as well. If you want to just serve static files, strip out the FCGI config and change the default document to index.html. Rather than creating a new vhost.conf file for every domain, just create one of these:

server {
  # Replace this port with the right one for your requirements
  listen 80 [default|default_server];  #could also be 1.2.3.4:80
 
  # Multiple hostnames separated by spaces.  Replace these as well.
  server_name star.yourdomain.com *.yourdomain.com; # Alternately: _
 
  root /PATH/TO/WEBROOT/$host;
 
  error_page 404 errors/404.html;
  access_log logs/star.yourdomain.com.access.log;
 
  index index.php index.html index.htm;
 
  # serve static files directly
  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }
 
  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    # By all means use a different server for the fcgi processes if you need to
    fastcgi_pass   127.0.0.1:YOURFCGIPORTHERE;
  }
 
  location ~ /\.ht {
    deny  all;
  }
}


  • ?
    보석 2011.10.31 21:59
    nginx는 /etc/nginx/sites-available/에다가 가상호스트를 만들 수 있는데요

    파일 내용이
    server
    {
    ....
    }
    이런식 인데요

    {{{서브도메인 blog.domain.com포함된 설정}}}
    server
    {
    server_name blog.domain.com;
    root /home/사용자/pubic_html/domain/blog;
    index index.php;
    }

    server
    {
    server_name domain.com www.domain.com;
    root /home/사용자/public_html/domain;
    index index.php;
    }

    이런식으로 설정해줬는데

    domain.com과 www.domain.com만 제대로 작동하고
    blog.domain.com은 도메인을 찾을 수 없다고 합니다?;;
    국내 사이트도 없어서 구글에서 외국 글 검색해서 만들어봤는데 잘 안되네요..                                       

리눅스

유용한 정보 및 자료

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
204 Server 우분투 nginx rewrite 보석 2011.11.03 235869
203 XE XE 특정 회원이 보낸 쪽지만 삭제하는 쿼리 보석 2013.08.23 121599
202 Server 우분투 mysql DB 파일 위치 변경 방법 패키지로 설치 했을 경우 보석 2013.08.26 57380
201 Server [리눅스] 새 계정 만들기/지우기, 사용자 아이디 추가/삭제; Create Account 1 보석 2011.08.31 39168
200 Server 리눅스용 무료 웹하드 <shade webhard> 설치하기 file 보석 2011.10.17 36136
199 Server [우분투] screen 명령어 보석 2013.02.04 33016
198 Server 우분투 리눅스에서 APM 설치하기 (웹서버 설정) 보석 2011.07.04 32846
197 XE XE 관리그룹만 글쓰기버튼 보이게 하기 보석 2012.11.02 31552
196 Server Startssl.com 무료 ssl 인증서 서버 설정 보석 2012.08.17 31199
195 XE 레벨아이콘과 그룹아이콘 동시에 출력하기 보석 2012.09.05 31098
194 XE XE 닉네임 글자수 제한 보석 2012.09.19 30815
193 XE XE 특정게시판만 코드 실행문 2 보석 2013.03.07 30193
192 XE XE 추천시 추천하는 사람도 포인트 받기 보석 2013.03.12 29682
191 Server 우분투 가상호스트 설정 보석 2011.05.15 28853
190 Server 우분투 Memcached 설치는 이렇게 보석 2011.10.19 28786
189 XE XE 1.5.X 용 nginx rewrite rule 2 보석 2013.02.22 28376
» Server Nginx 가상호스트 설정 1 보석 2011.10.31 27860
187 XE XE 1.7.X 용 nginx rewrite rule 보석 2013.02.22 27280
186 XE XE 추천수가 일정수준을 넘으면 게시판 이동시키기 6 보석 2013.03.07 27077
185 Server 링크하드 리눅스 설치 성공담 - 웹하드 WebHard Linux Install 보석 2011.10.17 27005
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11