Deploying any application as a WebApps projectThe WebApps platform is a versatile backend process management system that allows you to start and use applications that run their own network-facing servers in the background of your hosting account. Such applications expect to handle requests directly. There are many applications that may require to be run like this; for example, Node.js applications usually use their own web server to handle incoming requests, as well as most web-based applications written in Python. However, the WebApps platform is not limited to only running Node.js or Python applications. It allows any application that handles network requests to be run. For example, the following code shows an extremely simple web server that is implemented in just two lines of shell code:
In this article, we will create a WebApps project to run this simple web server. Warning: Note that this web server is not meant for production use and we would not recommend using it. This is a proof-of-concept for demonstration purposes only. If you do not see a WebApps section in the Control Panel of your hosting account, this tutorial may not be suitable for your particular hosting environment. Please contact our support team for more information. You need SSH access to the server in order to make the changes described in this tutorial. If you haven't set up SSH for your account yet, you should do this now. Note that you should also enable both "Network tools" and "Compiling tools" on the SSH Access page of the Control Panel of your hosting account. Creating the web serverThe following commands, when run over SSH, will create and configure the application. First, we create a directory to hold all files for this project:
After that, we create the
Creating the WebApps projectThere are two ways to create a WebApps project. One is from the WebApps page of the Control Panel of your hosting account. The other is using the command line interface over an SSH connection. Using the WebApps page of the Control PanelIn the "Engine" field, choose "Custom". The name of this project is "shell_web_server_demo". For "Domain" and "Subdomain", you can choose anything you like; we would recommend that you set up a new subdomain dedicated to your application. The last setting we need to add is "Deployment directory". In this case, it is For now, you should not enter anything in the "Start command" field: After you create the project, a port will be assigned to it automatically. You can use this port (red arrow) to edit the project and set up its "Start command": The "Start command" should be something like this:
Note that you have to update the username ("example" here) and the port number ("6086") in the command to match the username of your hosting account and the port assigned to the project. Using the command line interface over SSHIf you prefer to use the command line to manage the project, you can use the command line WebApps management tool. It is called Creating the WebApps project is a matter of running the following command:
At this point, we configure the WebApps project to use the TCP port that is automatically assigned to the project:
The final step you have to make is decide where on your website to deploy the project. You can create a new subdomain for it, or use an existing one. You can also make the application available in a subdirectory: The first step is to click on the "Edit" button (red arrow). This will load the settings of the project in the form under "Edit app". There, you should choose the domain and subdomain (blue arrows) at which to deploy the project. You can choose the "Web access path" as well; this is optional. Finally, after you click on the "Update" button and the settings are saved, you can start the project (green arrow). Your new web server will be automatically started and managed by the WebApps platform. HTTPS encryptionIt is important to note that the WebApps platform takes care of encryption automatically. This means that your WebApps project will be served over HTTPS even if your application does not support HTTPS explicitly (like this simple web server). This happens automatically for every project. In fact, you should not enable HTTPS connections for your application even if it does support them; the connection between WebApps and your project is done locally and is secure, and connections between visitors and the WebApps platform in front of your application is encrypted by our servers. |