MUDE is a module at the Civil Engineering and Geosciences faculty of Delft University of Technology: {{ site.tagline }}, taken by all first year students in the MSc degree programs Applied Earth Sciences (AES), Environmental Engineering (EE) and Civil Engineering (CE).
test.
\ No newline at end of file
We hope you are looking forward to kicking off your MSc program with the first MUDE lecture on Tuesday, September 3rd!
More information about the module will be provided in that session. For now you can see general information about the module [here](https://studiegids.tudelft.nl/a101_displayCourse.do?course_id=69347){:target="_blank"} as well as the course schedule via [MyTimetable](https://mytimetable.tudelft.nl/schedule){:target="_blank"}.
We know you are busy getting ready for the start of the year, but if you have any free time we encourage you to take a look at [this page for incoming students](https://mude.citg.tudelft.nl/incoming/){:target="_blank"} and try reviewing some of the material, depending on your prior experience.
If you have personal questions, you may send a request to MUDE-CEG@tudelft.nl. Please reserve general questions about the module until the end of the first lecture.
If you would like more information about the course contents before the first lecture, you can take a look at the [contents from last year](https://mude.citg.tudelft.nl/2023/){:target="_blank"}, or our [interactive online textbook](https://mude.citg.tudelft.nl/2023/book/intro.html){:target="_blank"}, but please note there will be significant changes, so only use it to get a general idea for what to expect!
description:Information about the setup and configuration of various webservers.
nav_order:1
nav_exclude:false
permalink:/webservers/
---
This document describes the setup and configuration of various webservers. At the moment, the servers have very different setups. We will try to align them over time, but initially, work will be limited to `mude` and `interactivetextbooks`.
List of active servers with Ubuntu is here, for reference:
```
edu01.citg.tudelft.nl
hub01.citg.tudelft.nl
interactivetextbooks.citg.tudelft.nl
mude-utilities.citg.tudelft.nl
mude.citg.tudelft.nl
pybox.citg.tudelft.nl
```
# Webserver File System
The webserver hosts websites via `nginx` and the files are located in `/var/web_server/htdocs/`.
# GitLab Runner
GitLab Runner is used to execute the CI/CD (Continuous Integration and Continuous Deployment) jobs defined in a GitLab project's `.gitlab-ci.yml` file. It can be installed on various platforms, including Linux, macOS, Windows, and can also run in Docker containers. In our case, we have GitLab Runner installed on the mude-utilities Linux server.
Currently, most of the mude repositories are using the runner #1020 (rU9Qxsz9J).
You can check this information via the [GitLab Runner Dashboard](https://gitlab.tudelft.nl/mude) -> **Build** -> **Runners**.
This runner is located on the `mude-utilities.citg.tudelft.nl` Ubuntu server. To check the status of the runner in the Linux terminal, use the following command:
```sh
sudo systemctl status gitlab-runner
```
# GitLab CI/CD
Note that the TU Delft GitLab (`gitlab.tudelft.nl`) has a limited set of features compared to EWI GitLab (`gitlab.ewi.tudelft.nl`).
There is a different setup on the `mude` and `interactivetextbooks` servers.
Here is the explanation for example `https://mude.citg.tudelft.nl/archive`
## GitLab CI/CD Pipeline Configuration
This configuration defines a CI/CD pipeline that deploys files to an archive directory on a remote server. The pipeline uses the latest Alpine Linux image and includes the following key sections:
### Stages
```yaml
stages:
-deploy
```
- Stages: Currently, only a deploy stage is defined. Typically, pipelines include test, build, and deploy stages.
Rules: The job triggers only on pushes to the main branch
```yaml
deploy-to-archive:
stage:deploy
#this part should be the same as the pre-defined ones.
- Debug Information: Displays current directory and lists files.
- Directory Preparation: Checks for src directory, creates it if missing, and moves necessary files into it.
File Syncing: Uses rsync to sync files to a temporary directory on the remote server.
- Remote Commands: Executes SSH commands to update the archive directory on the remote server:
Syncs files to the target directory.
Changes ownership and permissions.
Cleans up temporary files.
```yaml
environment:
name:production
url:https://mude.citg.tudelft.nl/archive
```
- Environment URL: Specifies the URL for the production environment.
Basically, this configuration ensures that only changes pushed to the main branch trigger the deployment, securely transfers files, and updates the remote server's archive directory.
This pipeline can be used for other server setup as well, but you need to define the CI/CD variables first.
## Setting Up CI/CD Variables
Navigate to your repository -> Settings -> CI/CD -> Variables
Define these variables:
1. MUDE_SERVER_ADDRESS: Current value = mude.citg.tudelft.nl
2. MUDE_SERVER_USER: Current value = kwangjinlee
3. MUDE_DEPLOYER_SSH_KEY: SSH private key for authentication
- This is already done for `mude.citg.tudelft.nl`
- First of all, create a ssh key using the following ssh-keygen command
```sh
ssh-keygen -t rsa -b 4096
```
- When you run this command:
- It will prompt you to choose a file location to save the key
- You'll have the option to set a passphrase (recommended for security)
- This generates two files:
- A private key (e.g., id_rsa)
- Define this as the MUDE_DEPLOYER_SSH_KEY CI/CD variable
- A public key (e.g., id_rsa.pub)
- Add this to ~/.ssh/authorized_keys on the server
This process enables SSH connection without specifying a key.
## Recommendations for Future Development
- Update the MUDE_SERVER_USER to ensure an authorized username is used.
- Consider adding additional stages (e.g., test, build) to the pipeline for a more comprehensive CI/CD process.
- Regularly review and update the SSH keys and server access permissions for security.
# `mude` Setup
To modify the server setup, SSH into `mude.citg.tudelft.nl`. You can use the command below:
All you need to do to set up the new subdomain is to write exactly as the example shows.
### Configuration Details
#### Alias
```nginx
alias/var/www/html/{domainname};
```
This sets the alias for the `/ {domain name}` location to the directory `/var/www/html/{domain name}`. When a request matches `/ {domain name}`, Nginx serves the files from this directory.
If you `cd /var/www/html`, you could see nothing except the default Nginx `index.html` file on the `mude.citg.tudelft.nl` Linux server. This is because the server is using a proxy. `/var/web_server/htdocs/` is where the actual contents stay.
#### Index Files
```nginx
indexindex.htmlindex.htmintro.html;
```
This specifies the default files to serve if a directory is requested. Nginx will look for `index.html`, `index.htm`, or `intro.html` in that order.
To add a new subdomain and `index.html` for the new website, use the command:
```bash
cd /var/web_server/htdocs/
sudo mkdir{domain name}
sudo nano {domain name}/index.html
```
Write down anything in the `index.html` file. Press `(Ctrl+X -> Y)` to save and exit from the nano text editor. In this way, your `index.html` file will be created successfully.
#### Try Files
```nginx
try_files$uri$uri/=404;
```
This directive attempts to serve the requested URI as a file or a directory. If neither exists, it returns a 404 error.
### Restarting Docker
After you finish the setup above, you need to restart the Docker container with the following commands: