Score:1

Multiple websites on nginx on one IP address

it flag

I checked out the Multiple websites on nginx, one IP but I have a small different situation.

I want to host three websites (one for thelounge and other two is ASP.NET Core web app which listens on different ports (5002, respectively 5003)) on same server (same IP address) but on different subdomains.

So, I bought domain from namecheap and I configured domain for the lounge like in picture:

enter image description here

I followed from Thomas Ward's answer step by step but I don't know for .net core web apps which listens different ports. I created service, kestrel service for .net core app in /etc/systemd/system/myapp.service

[Unit]
Description=my app

[Service]
WorkingDirectory=/home/anuser
ExecStart=/usr/bin/dotnet /home/anuser/MyApp.Web.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=info-editor
User=anuser
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

I activated above service and I ran it. All good, the website is active.

When trying to access editor.xxx.xxx then it redirects to first website (the lounge).

the nginx conf for thelounge (chat.xxxxx.conf) :

server {
server_name chat.xxxxx.xxxxx;

set $upstream 127.0.0.1:9000;
location / {
proxy_pass_header Authorization;
proxy_pass http://$upstream;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;

...
}

and for .net core web app (editor.xxxxx.conf)

server {
server_name editor.xxxxx.xxxx

set $upstream 127.0.0.1:5002;
location / {
proxy_pass_header Authorization;
proxy_pass http://$upstream;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection “”;
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
}
listen 80;
}

Of course I used ln command to make symbolic link to /sites-enabled

I restarted also nginx. But still redirects to thelounge

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.