'Deploy asp.net core and react on an apache centOS
I am trying to deploy my Asp.net core web with react on an Apache server but the resource and SPA files doesn't reload.
I want to deploy myapp in eg: domain.com/myapp
- myapp run
http://127.0.0.1:5050 - configuration in apache2
/etc/apache2/conf.d/myapp.conf
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
<Location /myapp >
ProxyPreserveHost On
ProxyPass http://127.0.0.1:5050/
ProxyPassReverse http://127.0.0.1:5050/
</Location>
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
RewriteRule /(.*) ws://127.0.0.1:5050/$1 [P]
ErrorLog /var/log/apache2/myapp-error.log
CustomLog /var/log/apache2/myapp-access.log common
</VirtualHost>
- create service
/etc/systemd/system/myapp.service
[Unit]
Description=MyApp .NET Web API running on CentOS
[Service]
WorkingDirectory=/var/netcore/myapp/
ExecStart=/usr/bin/dotnet /var/netcore/myapp/myapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=myapp
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
- paths
-
SPA : /var/netcore/myapp/ClientApp/build
-
Asp Net : /var/netcore/myapp
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
