Use same domain for front and backend Net core Angular application

  • Job DurationLess than a week
  • Project LevelBasic Level
  • Project deadlineExpired

Project detail

Hello there I have 2 application hosted on the server. 1 angular running with node.js on port 4000 and one net core running trough the kestrel on port 5000. The angular application falls back to index.html I can curl on the server localhost:4000 and get back data The net core application falls back to not found but I can curl on the server localhost:5000/weatherforecast and get back data. Both application have no error in logs. I have 2 virtual hosts for port 80 that are proxying respectively one 4000 port and one 5000 port

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName myapp.com
ServerAlias www.myapp.com
ErrorLog /var/log/apache2/myapp-error.log
CustomLog /var/log/apache2/myapp-access.log common
RewriteEngine On
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_NAME} =myapp.com [OR]
RewriteCond %{SERVER_NAME} =www.myapp.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:4000/
ProxyPassReverse / http://127.0.0.1:4000/
ServerName myapp.com
ServerAlias www.myapp.com
ErrorLog /var/log/apache2/myapp-error.log
CustomLog /var/log/apache2/myapp-access.log common
RewriteEngine On
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_NAME} =myapp.com [OR]
RewriteCond %{SERVER_NAME} =www.myapp.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

and 2 virtual host for port 443

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:4000/
ProxyPassReverse / http://127.0.0.1:4000/
ServerName myapp.com
ServerAlias www.myapp.com
ErrorLog /var/log/apache2/myapp-error.log
CustomLog /var/log/apache2/myapp-access.log common
RewriteEngine On
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/myapp.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/myapp.com/privkey.pem

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName myapp.com
ServerAlias www.myapp.com
ErrorLog /var/log/apache2/myapp-error.log
CustomLog /var/log/apache2/myapp-access.log common
RewriteEngine On
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/myapp.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/myapp.com/privkey.pem

however will display only the application on the first virtual host for port 443 the above file in this case 4000 but not both. I can make work one or the other but not togheter. They both work on http curl I am guessing something wrong to this last file virtual host

I pay 10 pound if you help me get site up and running with backend and frontend

Skills Required

Industry Categories

Freelancer type required for this project