로그인

검색

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
번호 분류 제목 글쓴이 날짜 조회 수
24 XE svn 으로 다운 받기 xe 보석 2011.09.10 17814
23 Server Startssl.com 무료 ssl 인증서 서버 설정 보석 2012.08.17 31199
22 Server Startssl.com 무료 ssl 인증서 받기 2 보석 2012.08.17 12975
21 Server ssl 항상 적용하기 + http->https로 rewrite 보석 2012.08.18 20010
20 Server Rewrite 묘듈 활성화 Apache rewrite 활성화하기 보석 2013.08.23 17585
19 KimsQ RBSHOP 킴스큐쇼핑몰 가입시 포인트 적립금으로 바꾸기 보석 2013.08.23 15071
18 Pydio Pydio AjaXplorer 업로드후 Impossible write into the AJXP_DATA_PATH folder ajaxplorer 나올때 보석 2016.05.18 181
17 Pydio Pydio AjaXplorer 버전별 다운로드 보석 2016.05.18 88
16 Pydio Pydio AjaXplorer Mcrypt Enabled, Security Brench, Server charset encoding, php output disabled 오류해결 보석 2016.05.18 106
15 Server Proftp 버전 및 프로그램명 숨기기 보석 2013.08.23 18300
14 Server nginx 첨부파일 용량 설정 보석 2012.04.02 18747
13 Server Nginx 버전 정보 숨기기 보석 2013.08.23 16925
12 Server nginx 무한 F5 막기 보석 2014.04.08 6527
» Server Nginx 가상호스트 설정 1 보석 2011.10.31 27860
10 Server mysql 튜닝 방법 보석 2013.08.25 17577
9 기타 MySQL 기본쿼리 : DELETE 문 보석 2013.03.14 15565
8 Server kimsq 파일 다운로드시 포인트 차감 설정 보석 2011.05.18 11305
7 KimsQ kimsq v1.1.0 기준 nginx rewrite rule 보석 2013.08.23 12778
6 Server Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 11.10 1 보석 2011.11.01 25692
5 Server Install Nginx, PHP5, PHP-FPM and MySQL on Ubuntu 11.04 보석 2011.10.31 25494
Board Pagination Prev 1 ... 2 3 4 5 6 7 8 9 10 11 Next
/ 11