mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
82 lines
1.9 KiB
Bash
82 lines
1.9 KiB
Bash
echo "If you haven't already, publish the Remotely Server app using the 'dotnet publish'
|
|
command (e.g. dotnet publish <path to csproj file> -o <output directory>).
|
|
The output directory is the app root path. This would typically be in /var/www/[appname]/.
|
|
"
|
|
read -p "Enter app root path: " appRoot
|
|
read -p "Enter app host (e.g. example.com): " appHost
|
|
|
|
|
|
|
|
# Install .NET Core Runtime.
|
|
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin
|
|
|
|
|
|
|
|
# Install Nginx
|
|
apt-get update
|
|
apt-get install nginx
|
|
|
|
systemctl start nginx
|
|
|
|
|
|
# Configure Nginx
|
|
nginxConfig="server {
|
|
listen 80;
|
|
server_name $appHost *.$appHost;
|
|
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;
|
|
}
|
|
}"
|
|
|
|
echo "$nginxConfig" > /etc/nginx/sites-available/remotely
|
|
|
|
ln -s /etc/nginx/sites-available/remotely /etc/nginx/sites-enabled/remotely
|
|
|
|
# Test config.
|
|
nginx -t
|
|
|
|
# Reload.
|
|
nginx -s reload
|
|
|
|
|
|
|
|
|
|
# Create service.
|
|
|
|
serviceConfig="[Unit]
|
|
Description=Remotely Server
|
|
|
|
[Service]
|
|
WorkingDirectory=$appRoot
|
|
ExecStart=/usr/bin/dotnet $appRoot/Server.dll
|
|
Restart=always
|
|
# Restart service after 10 seconds if the dotnet service crashes:
|
|
RestartSec=10
|
|
SyslogIdentifier=remotely
|
|
User=www-data
|
|
Environment=ASPNETCORE_ENVIRONMENT=Production
|
|
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target"
|
|
|
|
echo "$serviceConfig" > /etc/systemd/system/remotely.service
|
|
|
|
|
|
# Enable service.
|
|
systemctl enable remotely.service
|
|
# Start service.
|
|
systemctl start remotely.service
|
|
|
|
|
|
# Install Certbot and get SSL cert.
|
|
apt-get install certbot
|
|
|
|
certbot --nginx |