I am publishing a site created by sinatra on unicorn+nginx, and I would like to add another site, but I don't know how to do it, so please let me know.
Currently, it is as follows.(Excerpts only relevant parts)
Unicorn Configuration
listen "/tmp/unicorn_server.sock", backlog:1024
Configuring nginx
#unicorn
upstream unicorn_server{
server unix: /tmp/unicorn_server.sock;
}
# Site A
server{
listen80;
server_name site-a.com;
root/var/www/site-a/public;
location / {
proxy_pass http://unicorn_server;
}
}
I would like to add site B to this, but I have no idea what to do.
Should I launch another unicorn, create a new listen, and add it to nginx like site A?
Or do we have multiple listeners in one unicorn?
I wonder if unicorn can be launched multiple times in the first place...
It's my first time and I don't understand many things.
I would appreciate it if you could give me a reference site or a specific example of the configuration.
Please let me know if you need any more information.
Thank you for your cooperation.
ruby nginx sinatra unicorn
Unicorn for Site B must be launched separately.At this time, you must specify a different sock file than Site A in the configuration file.
(The example below specifies /tmp/unicorn_server_b.sock
.)
listen "/tmp/unicorn_server_b.sock", backlog:1024
You also need to change the nginx configuration.Add the configuration for site B to the configuration file.
(Assuming Site A has a domain of site-a.com and Site B has a domain of site-b.com)
#Configuring for Site A
upstream unicorn_server{
server unix: /tmp/unicorn_server.sock;
}
server{
listen80;
server_name site-a.com;
root/var/www/site-a/public;
location / {
proxy_pass http://unicorn_server;
}
}
# Configuration for Site B
upstream unicorn_server_b{
server unix: /tmp/unicorn_server_b.sock;
}
server{
listen80;
server_name site-b.com;
root/var/www/site-b/public;
location / {
proxy_pass http://unicorn_server_b;
}
}
© 2024 OneMinuteCode. All rights reserved.