简体   繁体   中英

configuring multiple domains with nginx

First of all there's already a server running on 80 port(with domain, let's say domainA.com ), and I have another domain(domainB.com). Here's what I'm trying to do.

80 port: domainA.com

3000 port: domainB.com

so If I make a request to domainB.com It shouldn't redirect to domainA.com:3000 but should actually works on the same server. and DNS server ip is set to the server as the same as domainA.com is connected to (so if I go to domainB.com it just redirects to domainA.com, I think I need to fix this part but I have no idea). how can I make this happen?

server {
    listen      80;
    server_name domainA.com;
    root /var/www/domainA;
}

server {
    listen       3000;
    server_name domainB.com ;
    root /var/www/domainB;
}

you now can access this sites via : domainA.com and domainB.com:333 also you can make both of them listen on port 80 : nginx can detect that request is coming for which domain and redirect request to that domain :

server {
    listen      80;
    server_name domainA.com;
    root /var/www/domainA;
}

server {
    listen       80;
    server_name domainB.com ;
    root /var/www/domainB;
}

see this : nginx server_names

source : diffrent domain on same ip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM