I am trying to host multiple ASP NET Core sites with different domains on Linux, Unbunt 18.04 and using nginx as reverse proxy.
These are the steps:
1) Creating new .conf files in /etc/nginx/sites-available
2) Creating folders in /var/www/ and uploadin the .net app
3) Creating new .service files for each .conf file
The default nginx .conf is unchanged.
The .conf files look like this:
server {
listen 80;
server_name domain;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
The .service files look like this:
[Unit]
Description=Event Registration Example
[Service]
WorkingDirectory=/var/www/example
ExecStart=/usr/bin/dotnet /var/www/example/example.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
With this configuration, even I deploy few sites, all of them are redirected to same content. My goal is to host multiple .net core apps on same server. How the configuration should look like?
.conf
fromsites-available
tosites-enabled
and thenreload
ingnginx
? – Pyrenees