How to create a web server?

Heyo,

I want to mess around with HttpService and force myself to practice web programming.
I want to set up my own simple webserver to mess around with.
I do not have the slightest idea where to begin. If one of you bright minds could point me to the right direction that would be awesome.

Thanks, :slight_smile:

6 Likes

You can actually setup a server on your own computer to play around with. Only studio will be able to connect to it though unless you unblock port 80 on your modem, router, and local machine. Running a server on your own machine helps you really get a feel for what is going on where as jumping straight to a web host everything it already setup for you and there is tons of bloat to get distracted in.

Are you running Windows or Linux? If it is a Mac then we can’t be friends. I’d look for a tutorial for the Apache Httpd server. It is pretty common and there are lots of resources for it and a large community. Once you get it setup, you can write a html page and request it from studio using IP address 127.0.0.1 (the loopback address).

If you really wanted to get a solid understanding of how servers work, it isn’t too hard to write your own basic HTTP/1.1 server. The OS will take care of the IP/TCP layers and you simply receive plain text which you parse in HTTP format. The hardest part is figuring out how to use sockets to listen on a port.

Finally, if you really want your own server then what you are looking for is web hosting. In addition, unless you want to type in your servers IP everywhere, you will need a domain (DNS address, that fancy website name that translates into an IP address like 14.165.165.64). You can get them separately or from the same provider, but it is easier to setup when you get them at the same place. Note that the domain isn’t 100% required though. These hosts have all sorts of ways to access the server once you’ve rented it, but the most common way is through a web interface called CPanel. There are lots of tutorials on how to use it.

8 Likes

I think node.jsexpress module would be the best for getting started with web servers. It’s really easy to mess up writing an HTTP server from scratch and you would have to implement everything from multithreaded handling of requests and URL parsing to cookies and body request parsers which is just annoying. With express, most of these common requirements have already been done by the community or are included within express itself so you can worry about the app, not the complexities of creating a foundation from scratch.

As for hosting, there’s not really a need for Apache or Nginx. You can just upload your code to a server or port forward your network and host it on your computer and then simply run your server using forever which try and keep your server running forever (as the name implies).

Hope this helps,
rad

2 Likes

I suggest you using website called https://infinityfree.net/ for testing purposes.

infinityfree is free hosting plans includes a free domain name of your choice. Choose the free website domain that fits with full PHP, MySQL support.

But also remember Rolobx studio cannot access websites that dont own ssl so you should use proxy called https://cors-anywhere.herokuapp.com

2 Likes

Quick PSA: Don’t use PHP! It’s very easy to mess up security and it’s generally annoying to use. One example of easily messed up security and annoying behavior is mysql_real_escape_string vs mysql_escape_string. It’s really easy to use the wrong one as a first time user which creates security vulnerabilities without you knowing. That’s only the top of the iceberg, I’d suggest looking at PHP: a fractal of bad design to see all of the challenges you will face if you decide to use PHP.

3 Likes