From f05e9c66981c85474ac7010e50b702e321539d16 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 28 Dec 2021 12:07:10 +0100 Subject: [PATCH 1/5] Add RHEL8 Support for Server install --- Server.Installer/Models/WebServerType.cs | 1 + Server.Installer/Program.cs | 1 + .../Resources/RHEL8_Nginx_Install.sh | 157 ++++++++++++++++++ Server.Installer/Server.Installer.csproj | 2 + Server.Installer/Services/ServerInstaller.cs | 1 + 5 files changed, 162 insertions(+) create mode 100644 Server.Installer/Resources/RHEL8_Nginx_Install.sh diff --git a/Server.Installer/Models/WebServerType.cs b/Server.Installer/Models/WebServerType.cs index e7ad4db3a..ac488ca81 100644 --- a/Server.Installer/Models/WebServerType.cs +++ b/Server.Installer/Models/WebServerType.cs @@ -14,6 +14,7 @@ public enum WebServerType UbuntuNginx, CentOsCaddy, CentOsNginx, + Rhel8Nginx, IisWindows } } diff --git a/Server.Installer/Program.cs b/Server.Installer/Program.cs index ca418323d..09b2a12dd 100644 --- a/Server.Installer/Program.cs +++ b/Server.Installer/Program.cs @@ -103,6 +103,7 @@ public static async Task Main(string[] args) "Nginx on Ubuntu", "Caddy on CentOS", "Nginx on CentOS", + "Nginx on RHEL8" "IIS on Windows Server 2016+"); if (Enum.TryParse(webServerType, out var result)) diff --git a/Server.Installer/Resources/RHEL8_Nginx_Install.sh b/Server.Installer/Resources/RHEL8_Nginx_Install.sh new file mode 100644 index 000000000..57e58e398 --- /dev/null +++ b/Server.Installer/Resources/RHEL8_Nginx_Install.sh @@ -0,0 +1,157 @@ +#!/bin/bash +echo "Thanks for trying Remotely!" +echo + +Args=( "$@" ) +ArgLength=${#Args[@]} + +for (( i=0; i<${ArgLength}; i+=2 )); +do + if [ "${Args[$i]}" = "--host" ]; then + HostName="${Args[$i+1]}" + elif [ "${Args[$i]}" = "--approot" ]; then + AppRoot="${Args[$i+1]}" + fi +done + +if [ -z "$AppRoot" ]; then + read -p "Enter path where the Remotely server files should be installed (typically /var/www/remotely): " AppRoot + if [ -z "$AppRoot" ]; then + AppRoot="/var/www/remotely" + fi +fi + +if [ -z "$HostName" ]; then + read -p "Enter server host (e.g. remotely.yourdomainname.com): " HostName +fi + +echo "Using $AppRoot as the Remotely website's content directory." + +dnf update +dnf -y install curl +dnf -y install gnupg + +# Install .NET Core Runtime. +sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm + +#dnf -y install aspnetcore-runtime-5.0 +dnf -y install dotnet-host dotnet-hostfxr-6.0 dotnet-runtime-6.0 + + # Install other prerequisites. +dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm +subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms +dnf -y install dnf-utils +dnf -y install unzip +dnf -y install acl +dnf -y install glibc-devel +dnf -y install libgdiplus +dnf -y install nginx + +# Set permissions on Remotely files. +setfacl -R -m u:nginx:rwx $AppRoot +chown -R nginx:nginx $AppRoot +chmod +x "$AppRoot/Remotely_Server" + + +# Install Nginx +dnf -y install nginx + +systemctl start nginx + + +# Configure Nginx +nginxConfig="server { + listen 80; + server_name $HostName *.$HostName; + location / { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection close; + 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; + } + + location /_blazor { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection \"Upgrade\"; + proxy_set_header Host \$host; + proxy_cache_bypass \$http_upgrade; + } + location /AgentHub { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection \"Upgrade\"; + proxy_set_header Host \$host; + proxy_cache_bypass \$http_upgrade; + } + + location /ViewerHub { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection \"Upgrade\"; + proxy_set_header Host \$host; + proxy_cache_bypass \$http_upgrade; + } + location /CasterHub { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection \"Upgrade\"; + proxy_set_header Host \$host; + proxy_cache_bypass \$http_upgrade; + } +}" + +echo "$nginxConfig" > /etc/nginx/conf.d/remotely.conf + +# Test config. +nginx -t + +# Reload. +nginx -s reload + + +# Create service. + +serviceConfig="[Unit] +Description=Remotely Server + +[Service] +WorkingDirectory=$AppRoot +ExecStart=/usr/local/bin/dotnet $AppRoot/Remotely_Server.dll +Restart=always +# Restart service after 10 seconds if the dotnet service crashes: +RestartSec=10 +SyslogIdentifier=remotely +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 + +firewall-cmd --permanent --zone=public --add-service=http +firewall-cmd --permanent --zone=public --add-service=https +firewall-cmd --reload + +# Install Certbot and get SSL cert. +dnf -y install python3-certbot-nginx + +# SELinux policies +setsebool -P httpd_can_network_connect 1 + +certbot --nginx diff --git a/Server.Installer/Server.Installer.csproj b/Server.Installer/Server.Installer.csproj index 107a54c52..30468b27e 100644 --- a/Server.Installer/Server.Installer.csproj +++ b/Server.Installer/Server.Installer.csproj @@ -18,6 +18,7 @@ + @@ -26,6 +27,7 @@ + diff --git a/Server.Installer/Services/ServerInstaller.cs b/Server.Installer/Services/ServerInstaller.cs index 5540530a7..2464709e2 100644 --- a/Server.Installer/Services/ServerInstaller.cs +++ b/Server.Installer/Services/ServerInstaller.cs @@ -135,6 +135,7 @@ private async Task LaunchExternalInstaller(CliParams cliParams) WebServerType.UbuntuNginx => "Ubuntu_Nginx_Install.sh", WebServerType.CentOsCaddy => "CentOS_Caddy_Install.sh", WebServerType.CentOsNginx => "CentOS_Nginx_Install.sh", + WebServerType.Rhel8Nginx => "RHEL8_Nginx_Install.sh", WebServerType.IisWindows => "IIS_Windows_Install.ps1", _ => throw new Exception("Unrecognized reverse proxy type."), }; From b0e205b2dceb2371332388e0694ecdfb984f6c09 Mon Sep 17 00:00:00 2001 From: Martin Juhl Date: Tue, 28 Dec 2021 13:43:40 +0100 Subject: [PATCH 2/5] Change from dotnet 6 to 5 --- Server.Installer/Resources/RHEL8_Nginx_Install.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Server.Installer/Resources/RHEL8_Nginx_Install.sh b/Server.Installer/Resources/RHEL8_Nginx_Install.sh index 57e58e398..f1c677e96 100644 --- a/Server.Installer/Resources/RHEL8_Nginx_Install.sh +++ b/Server.Installer/Resources/RHEL8_Nginx_Install.sh @@ -1,4 +1,6 @@ #!/bin/bash +DOTNETVERSION="5.0" + echo "Thanks for trying Remotely!" echo @@ -31,11 +33,8 @@ dnf update dnf -y install curl dnf -y install gnupg -# Install .NET Core Runtime. -sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm - -#dnf -y install aspnetcore-runtime-5.0 -dnf -y install dotnet-host dotnet-hostfxr-6.0 dotnet-runtime-6.0 +# Install Dotnet +dnf -y install dotnet-host dotnet-hostfxr-$DOTNETVERSION dotnet-runtime-$DOTNETVERSION # Install other prerequisites. dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm @@ -125,7 +124,7 @@ Description=Remotely Server [Service] WorkingDirectory=$AppRoot -ExecStart=/usr/local/bin/dotnet $AppRoot/Remotely_Server.dll +ExecStart=/usr/bin/dotnet $AppRoot/Remotely_Server.dll Restart=always # Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 From edfc85b749ece920e4ce0fe6677a589b10d6e788 Mon Sep 17 00:00:00 2001 From: Martin Juhl Date: Tue, 28 Dec 2021 13:44:52 +0100 Subject: [PATCH 3/5] Reorder installs --- Server.Installer/Resources/RHEL8_Nginx_Install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Server.Installer/Resources/RHEL8_Nginx_Install.sh b/Server.Installer/Resources/RHEL8_Nginx_Install.sh index f1c677e96..8d3819c2b 100644 --- a/Server.Installer/Resources/RHEL8_Nginx_Install.sh +++ b/Server.Installer/Resources/RHEL8_Nginx_Install.sh @@ -33,9 +33,6 @@ dnf update dnf -y install curl dnf -y install gnupg -# Install Dotnet -dnf -y install dotnet-host dotnet-hostfxr-$DOTNETVERSION dotnet-runtime-$DOTNETVERSION - # Install other prerequisites. dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms @@ -46,6 +43,9 @@ dnf -y install glibc-devel dnf -y install libgdiplus dnf -y install nginx +# Install Dotnet +dnf -y install dotnet-host dotnet-hostfxr-$DOTNETVERSION dotnet-runtime-$DOTNETVERSION + # Set permissions on Remotely files. setfacl -R -m u:nginx:rwx $AppRoot chown -R nginx:nginx $AppRoot From a961a0ad9a9705d397f8f76145814d9f44b5e2c4 Mon Sep 17 00:00:00 2001 From: Martin Juhl Date: Tue, 28 Dec 2021 16:10:09 +0100 Subject: [PATCH 4/5] Bump setup-dotnet to 2.2.0 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f90e03106..64ffb0688 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,7 +123,7 @@ jobs: # Install the .NET Core workload - name: Install .NET Core - uses: actions/setup-dotnet@v1.9.0 + uses: actions/setup-dotnet@v2.2.0 with: dotnet-version: 6.0.x From 0f1a2f389d85feb721d8abf557d933e7d96a2b46 Mon Sep 17 00:00:00 2001 From: Martin Juhl Date: Tue, 28 Dec 2021 16:11:30 +0100 Subject: [PATCH 5/5] Rollback --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64ffb0688..f90e03106 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,7 +123,7 @@ jobs: # Install the .NET Core workload - name: Install .NET Core - uses: actions/setup-dotnet@v2.2.0 + uses: actions/setup-dotnet@v1.9.0 with: dotnet-version: 6.0.x