Залил на VPS два сайта, настроил unicorn на два разных порта и nginx на два разных порта, все работает за исключением того что при переходе по ссылке вида domain1.ru:81 переходит на второй сайт... как привязать первый домен к 80 порту а второй к 81 и чтобы на первом домене не открывался второй сайт при использовании порта второго сайта?
nginx domain1
upstream unicorn {
server unix:/home/demo/application/shared/run/unicorn.sock fail_timeout=0;
}
server {
listen domain1.ru:80;
server_name domain1.ru;
root /home/demo/application/current/public;
try_files $uri/index.html $uri.html $uri @app;
location ^~ /assets/ {
expires max;
add_header Cache-Control public;
}
location @app {
proxy_pass http://unicorn;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/demo/application/current/public;
}
}
nginx domain2
upstream unicorn1 {
server unix:/home/demo/application1/shared/run/unicorn.sock fail_timeout=0;
}
server {
listen 81 default;
server_name 148.176.100.46;
root /home/demo/application1/current/public;
try_files $uri/index.html $uri.html $uri @app;
location ^~ /assets/ {
expires max;
add_header Cache-Control public;
}
location @app {
proxy_pass http://unicorn1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/demo/application1/current/public;
}
}
unicorn domain 1
worker_processes 4
root = '/home/demo/application'
rails_root = "#{root}/current"
working_directory "/home/demo/application/current" # available in 0.94.0+
listen "#{root}/shared/run/unicorn.sock", :backlog => 64
listen 8080, :tcp_nopush => true
timeout 30
pid "#{root}/shared/run/unicorn.pid"
stderr_path "#{rails_root}/log/unicorn_error.log"
stdout_path "#{rails_root}/log/unicorn.log"
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
check_client_connection
run_once = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
if run_once
run_once = false # prevent from firing again
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
unicorn второго домена
worker_processes 4
root = '/home/demo/application1'
rails_root = "#{root}/current"
working_directory "/home/demo/application1/current" # available in 0.94.0+
listen "#{root}/shared/run/unicorn.sock", :backlog => 64
listen 8081, :tcp_nopush => true
timeout 30
pid "#{root}/shared/run/unicorn.pid"
stderr_path "#{rails_root}/log/unicorn_error.log"
stdout_path "#{rails_root}/log/unicorn.log