본문 바로가기
서버/개발환경

nginx로 멀티도메인

by 아카이sun 2018. 9. 6.

하나의 서비스에서 접속방법을 달리하고싶을때.


default.conf의 설정



server {

listen 80 default_server;

listen [::]:80 default_server;


  server_name  www.site.com;

  

  access_log  /var/log/nginx/blog.access.log;

  error_log  /var/log/nginx/blog.error.log;


  index index.php index.html index.htm index.nginx-debian.html;


  root /var/www;

  

  location / {

      

  }

  

  location /path {

    try_files $uri $uri/ /path/index.php?/$request_uri;

  }


  location ~ \.php$ {

      try_files $uri =404;

      fastcgi_split_path_info ^(.+\.php)(/.+)$;

      fastcgi_pass   unix:/run/php/php7.0-fpm.sock;

      fastcgi_index  index.php;

      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

      include        fastcgi_params;

  }


  location ~ /\.ht {

      deny all;

  }

}


여기에 www대신 다른 prefix를 붙이고 싶다면??


api.conf를 만들어서 작성한다.



server {

  listen 80;


  server_name  api.site.com;

  

  if ($request_uri ~ "/path/sub_path/(.*)"){

    return 301 http://www.site.com$request_uri;

  }

}


'서버 > 개발환경' 카테고리의 다른 글

리눅스에 크롬 설치하기  (0) 2018.09.29
openssl 설치하기  (0) 2018.09.06
도커 설치하기  (0) 2018.08.17
yum 실행시 오류  (0) 2018.02.21
리눅스 현지시간 설정  (0) 2017.10.19

댓글