Skip to content

Setup FreeCC Domain

Chunhua "Leo" Liao edited this page Oct 29, 2019 · 12 revisions

The FreeCC domain freecompilercamp.org is managed on GoDaddy. Assume the IP of server hosting FreeCC is <aws_ip>.

Point FreeCC domain to <aws_ip>

On the Godaddy website, go to the DNS setting of freecompilercamp.org. Add new records and values

  • @, It refers to domains freecompilercamp.org., value set to <aws_ip>, Type A
  • www , this is for www.freecompilercamp.org, value set to @, Type A
  • classroom, this is fo classroom.freecompilercamp.org , value set to <aws_ip>, Type A
  • lab , this is for lab.freecompilercamp.org, used for hosting the PWC engine, value set to <aws_ip>, Type A
  • .lab , value set to <aws_ip> Keep the rest sections as default values. Save and wait for one hour or more until the entries take effect.

Setup the server to process the FreeCC domain.

The server may only open a few specific ports due to security concerns. Other than common ports http(80) and https (443), we may need at least two more ports

  • <pt1>: for the PWC sandbox server . We use port 3000 for the container running the PWC sandbox server
  • <pt2>: for the main website . We use port 4000 for the container hosting the main website.

The sandbox, PWC server that uses port 3000, runs in the docker container. When a regular request from port 80 to sandbox is coming, we need first forward that request to the unique port <pt1> and then pass to the docker port 3000. To do this, add the following code to Apache configuration, which is located at /etc/apache2/sites-available/000-default.conf.

<VirtualHost *:80>
        ServerName lab.freecompilercamp.org
        ProxyPass / http://lab.freecompilercamp.org:<pt1>/
</VirtualHost>

So, any access to lab.freecompilercamp.org will be passed to lab.freecompilercamp.org:<pt1>. Since we have mounted port <pt1> to docker port 3000 during deployment, all domain setting for PWC server is done.

The main website is hosted by Jekyll, which uses port 4000 by default in the docker container. During deployment, we have assign host port <pt2> to its docker port 4000. The rest job is to add proper forwarding in the same Apache configuration file above.

<VirtualHost *:80> 
        ProxyPreserveHost On
        ServerName classroom.freecompilercamp.org
        ProxyPass / http://classroom.freecompilercamp.org:<pt2>/
        ProxyPassReverse / http://classroom.freecompilercamp.org:<pt2>/
</VirtualHost> 

<VirtualHost *:80> 
        ServerName www.freecompilercamp.org
        ProxyPass / http://classroom.freecompilercamp.org:<pt2>/
</VirtualHost> 

<VirtualHost *:80> 
        ServerName freecompilercamp.org
        ProxyPass / http://classroom.freecompilercamp.org:<pt2>/
</VirtualHost> 

The subdomain classroom is used for flexibility. In the future, after applying the user account system a new landing page with authorization might be inserted before the classroom interface. That landing page would use the root domain freecompilercamp.org and direct user to the classroom.freecompilercamp.org after logging in.

Restart Apache server to apply the new configuration. Users don't need to handle any special port, they can input the original web address freecompilercamp.org as usual. The server will automatically forward the requests to proper docker containers.