Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RHEL8 Support for Server install #427

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Server.Installer/Models/WebServerType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum WebServerType
UbuntuNginx,
CentOsCaddy,
CentOsNginx,
Rhel8Nginx,
IisWindows
}
}
1 change: 1 addition & 0 deletions Server.Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(webServerType, out var result))
Expand Down
156 changes: 156 additions & 0 deletions Server.Installer/Resources/RHEL8_Nginx_Install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/bin/bash
DOTNETVERSION="5.0"

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 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

# 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
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/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
2 changes: 2 additions & 0 deletions Server.Installer/Server.Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ItemGroup>
<None Remove="Resources\CentOS_Caddy_Install.sh" />
<None Remove="Resources\CentOS_Nginx_Install.sh" />
<None Remove="Resources\RHEL8_Nginx_Install.sh" />
<None Remove="Resources\IIS_Windows_Install.ps1" />
<None Remove="Resources\Ubuntu_Caddy_Install.sh" />
<None Remove="Resources\Ubuntu_Nginx_Install.sh" />
Expand All @@ -26,6 +27,7 @@
<ItemGroup>
<EmbeddedResource Include="Resources\CentOS_Nginx_Install.sh" />
<EmbeddedResource Include="Resources\CentOS_Caddy_Install.sh" />
<EmbeddedResource Include="Resources\RHEL8_Nginx_Install.sh" />
<EmbeddedResource Include="Resources\IIS_Windows_Install.ps1" />
<EmbeddedResource Include="Resources\Ubuntu_Nginx_Install.sh" />
<EmbeddedResource Include="Resources\Ubuntu_Caddy_Install.sh" />
Expand Down
1 change: 1 addition & 0 deletions Server.Installer/Services/ServerInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
};
Expand Down