1

I'm trying to put two services running on apache for ubuntu at the same time, both works, but only one works at a time.

Apache configuration:

<VirtualHost *:80>  
   ServerName webapp1.org
   ServerAlias *.webapp1.org
   ProxyPreserveHost On  
   ProxyPass / http://127.0.0.1:5000/  
   ProxyPassReverse / http://127.0.0.1:5000/  
   RewriteEngine on  
   RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]  
   RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]  
   RewriteRule /(.*) ws://127.0.0.1:5000/$1 [P]  
   ErrorLog /var/log/apache2/netcore-error.log  
   CustomLog /var/log/apache2/netcore-access.log common  
</VirtualHost>

<VirtualHost *:80>
   ServerName webapp2.org
   ServerAlias *.webapp2.org
   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:5001/
   ProxyPassReverse / http://127.0.0.1:5001/
   RewriteEngine on  
   RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]  
   RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]  
   RewriteRule /(.*) ws://127.0.0.1:5001/$1 [P]  
   ErrorLog /var/log/apache2/netcore-error.log  
   CustomLog /var/log/apache2/netcore-access.log common  
</VirtualHost>

And below each service:

[Unit]  
Description=ASP .NET Web Application  
[Service]  
WorkingDirectory=/var/netcore/netcoreapp3.1
ExecStart=/usr/bin/dotnet /var/netcore/netcoreapp3.1/FooBarMvc.dll 
Restart=always  
RestartSec=10  
SyslogIdentifier=netcore-mvc  
User=www-data  
Environment=ASPNETCORE_ENVIRONMENT=Production  
[Install]  
WantedBy=multi-user.target

[Unit]
Description=ASP .NET WebAPI Application
[Service]
WorkingDirectory=/var/netcore/netcoreapp3.1/webapi
ExecStart=/usr/bin/dotnet /var/netcore/netcoreapp3.1/webapi/FooBarWebApi.dll
Restart=always
RestartSec=10
SyslogIdentifier=netcore-webapi
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target

According to Microsoft documentation, the second service should respond on port 5001, but it doesn't.

How to make both services run at the same time?

Should I actually put two services running on Linux, or would just one be enough?

Thanks

PS: I tried this reference, but it didn't work.

Host multiple asp.net core web application under a single linux server

7
  • The Unit descriptions are identical. What makes the first service use port 5000 and the second 5001?
    – omajid
    Jul 17, 2020 at 13:48
  • 1
    This question is quite independent of Apache httpd (I'm tempted to remove the tag): Apache httpd happily proxies both ports, but it relies on something answering there, which seems to be your problem. Also, it seems to be a configuration- rather than a programming question, which makes it off-topic on stackovervlow (help center)
    – Olaf Kock
    Jul 17, 2020 at 14:44
  • @omajid read again. Unit description are not equal.
    – Marcio
    Jul 18, 2020 at 14:30
  • @Olaf Kock this question impacts on test environment. Could you show me the stackoverflow rules that I can't open a question for environment problems reflecting on dotnet programming? Then what is the use of the "Apache" and "Linux" hashtag available to mark this issue? I need to show the full scenario to get answers for this problem.
    – Marcio
    Jul 18, 2020 at 14:38
  • 1
    @user2250504 im facing the same issue. have u solved the issue? i get the error (code=dumped, signal=ABRT)
    – SU7
    Jul 21, 2020 at 13:23

1 Answer 1

1

Not sure if you already resolved the issue, but you have to configure your application to run on a specific port number. By default it will start on port 5000, but if you want your other application to start on port 5001 you have to configure it.

Here you will find an excellent article how to configure the URLs for your application https://andrewlock.net/5-ways-to-set-the-urls-for-an-aspnetcore-app/

I configured my services by adding command argument like:

ExecStart=/usr/bin/dotnet /var/netcore/netcoreapp3.1/webapi/FooBarWebApi.dll --urls "http://localhost:5001"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.