OpenLiteSpeed Rails
Jun 28, 2024
Example Virtual Host so web server can handle the tra c for Rails How to Access the Installed Software From a terminal on your local computer, connect to the server as root, like so: ssh root@use_your_server_ip Be sure to substitute the server’s public IP address for use_your_server_ip . Web Server Control Panel Access Get the WebAdmin admin password: General cat .litespeed_password Visit https://use_your_server_ip:7080 to access WebAdmin in a browser. https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 4/119/22/2020 Rails | Images | Cloud | LiteSpeed Documentation [/patch-2/imgs/cloud/Cloud/wpapp-6.png] By default, WebAdmin uses port 7080. To allow access to 7080 from your IP(e.g. 1.2.3.4): ufw allow from 1.2.3.4 to any port 7080 You can also allow all IPs access to port 7080: ufw allow 7080 https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 5/119/22/2020 Rails | Images | Cloud | LiteSpeed Documentation We suggest turning this port off once you''ve nished setup: ufw delete allow 7080 Optional Setup Enable HTTPS Setting up an SSL certi cate enables HTTPS on the web server, which secures the tra c between the server and the clients connecting to it. Certbot is a free and automated way to set up SSL certi cates on a server. Step 1. Register Domain To use Certbot, you’ll need a registered domain name and DNS records: An A record from the domain (e.g., example.com ) to the server’s IP address An A record from the domain prefaced with www (e.g., www.example.com ) to the server’s IP address. Step 2. Add Domain to Listener Navigate to OpenLiteSpeed Web Server WebAdmin > Listeners, and add Your Domain to HTTP/HTTPS. [/patch-2/imgs/cloud/Cloud/listener-1.png] Step 3. Certbot Once the DNS records are set up, you can generate the SSL certi cate. Be sure to substitute the correct domain name in the following command: https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 6/119/22/2020 Rails | Images | Cloud | LiteSpeed Documentation certbot certonly --webroot -w /var/www/html/ -d example.com -d www.example.com If certi cate veri cation is a success, you should nd your certi cate les stored in /etc/letsencrypt/ Step 4. Set SSL for HTTPS [/patch-2/imgs/cloud/Cloud/wpapp-7.png] Navigate to OpenLiteSpeed Web Server WebAdmin > Listeners > SSL, and edit the following three items: Private Key File = /etc/letsencrypt/live/example.com/privkey.pem Certi cate File = /etc/letsencrypt/live/example.com/fullchain.pem Chained Certi cate = Yes Save and perform a Graceful Restart. Now your server should support TLS1.1, TLS 1.2, and TLS 1.3. Step 5. Redirect HTTP to HTTPS https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 7/119/22/2020 Rails | Images | Cloud | LiteSpeed Documentation [/patch-2/imgs/cloud/Cloud/wpapp-8.png] HTTPS tra c on port 443 is already allowed through the rewall. After you set up HTTPS, you can optionally rewrite all HTTP tra c to HTTPS. Add the following rules to OpenLiteSpeed Web Server WebAdmin > Virtual Hosts > Rewrite > Rewrite Rules RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://example.com/$1 [R,L] Method for Uploading Files You can serve les from the web server by adding them to the web root using SFTP [https://www.digitalocean.com/community/tutorials/how-to-use-sftp-to-securely- transfer- les-with-a-remote-server] or other tools. Frequently Asked Questions How do I Reset my Web Server WebAdmin Password? If you forget your password, you may run the following command to reset it: https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 8/119/22/2020 Rails | Images | Cloud | LiteSpeed Documentation /usr/local/lsws/admin/misc/admpass.sh It will ask for the WebAdmin username, which should be admin . Then, enter your new password. How do I Create Additional Virtual Hosts? Auto Setup via Script This method will automatically set up Listener/VirtualHost/Force SSL/Let''s Encrypt/WordPress. Interactive mode wget https://raw.githubusercontent.com/litespeedtech/ls-cloud- image/master/Setup/vhsetup.sh chmod +x vhsetup.sh bash vhsetup.sh Or just run the script without downloading it: /bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud- image/master/Setup/vhsetup.sh ) CLI mode wget https://raw.githubusercontent.com/litespeedtech/ls-cloud- image/master/Setup/vhsetup.sh chmod +x vhsetup.sh bash vhsetup.sh -d www.example.com -le admin@example.com -f -w Or just run the script without downloading it: /bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud- image/master/Setup/vhsetup.sh ) -d www.example.com -le admin@example.com -f -w Please be sure that your domain is already pointing to the server when using -le YOUR_EMAIL Please be sure that your environment has php/sql service/sql root password when using -w Manual Setup https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 9/11 9/22/2020 Rails | Images | Cloud | LiteSpeed Documentation By default, OpenLiteSpeed has an example virtual host already created. You can create more virtual hosts if you like. See Create Virtual Hosts on OpenLiteSpeed [https://openlitespeed.org/kb/setting- up-name-based-virtual-hosting-on-openlitespeed/]. How do I upgrade OpenLiteSpeed to latest stable version? OpenLiteSpeed was installed from the LiteSpeed repository, so you can simply use the system update to update OpenLiteSpeed to the latest stable version. $ sudo apt-get update && sudo apt-get upgrade openlitespeed -y How do I Run Rails Server? Since the image comes with the OpenLiteSpeed web server already, we did not install an extra webpacker package. You can do so with the following steps: 1. Install yarn package curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update sudo apt install yarn -y 2. Install webpacker package rails webpacker:install 3. Allow rewall port 3000 ufw allow 3000 4. Start built-in web server rails server -b 0.0.0.0 https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 10/119/22/2020 Rails | Images | Cloud | LiteSpeed Documentation Last update: September 22, 2020 https://docs-stage.ls.com/patch-2/cloud/images/rails-ali/ 11/11">