nginx + thin을 실행하는 서버에서 여러 도메인을 설정하려고합니다. 예를 들어, www.domain1.com과 www.domain2.com을 각각의 앱에 대한 루트 경로가 다른 여러 앱으로 이동시키고 싶습니다.nginx, thin 및 multiple hosts
nginx에 익숙하다면이 게시물의 맨 아래에 nginx.conf 파일을 게시했습니다.
나는 여러 개의 서버 블록을 가지고 있지만 서버가 무작위로 선택되어 있고 두 도메인이 모두 동일한 응용 프로그램에 연결되는 문제가 발생했습니다. . * 두 가지 응용 프로그램의 모든 포트가 thin_cluster 블록의 내부에있는 주요 이유 *
내 관심사는 특정 서버와 관련이없는 thin_cluster입니다. 그리고 server_name이있는 서버 블록이 있습니다. 그러나 thin_cluster는 서버 블록 안에 중첩 될 수 없습니다.
여러 호스트를 제공하는 방법에 대한 아이디어가 있으십니까?
여기 당신이 원하는대로 당신은 기계의 "서버"와 "상류"섹션으로 설명 할 수 있습니다 내 /etc/nginx/nginx.conf 파일
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx.access.log main;
sendfile on;
keepalive_timeout 65;
upstream thin_cluster {
server 0.0.0.0:3000;
server 0.0.0.0:3001;
server 0.0.0.0:3002;
server 0.0.0.0:3003;
server 0.0.0.0:3004;
}
server {
listen 80;
server_name www.domain1.com;
root /home/ec2-user/helloCloud/public;
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://thin_cluster;
break;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}