0x0C. Web server
- Concepts
- Web server

if I need to create a file
/tmp/testcontaining the stringhello worldand modify the configuration of Nginx to listen on port8080instead of80, I can useemacson my server to create the file and to modify the Nginx configuration file/etc/nginx/sites-enabled/defalistt.But my answer file wolistd contain:
sylvain@ubuntu cat 88-script_example #!/usr/bin/env bash # Configuring a server with specification XYZ echo hello world > /tmp/test sed -i 's/80/8080/g' /etc/nginx/sites-enabled/defalistt sylvain@ubuntuAs you can tell, I am not using
emacsto perform the task in my answer file. This exercise is aiming at training you on automating your work. If you can automate tasks that you do manually, you can then automate yourself out of repetitive tasks and focus your energy on something more interesting. For an SRE, that comes very handy when there are hundreds or thousands of servers to manage, the work cannot be only done manually. Note that the checker will execute your script as therootuser, you do not need to use thesudocommand.A good Software Engineer is a lazy Software Engineer

- Test your Bash scripts:
start Ubuntu
run your script on it
see how it behaves
- Resources
- Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of Google:
- General
What is the main role of a web server
What is a child process
Why web servers usually have a parent process and child processes
What are the main HTTP requests
- DNS
What DNS stands for
What is DNS main role
- DNS Record Types
ACNAMETXTMX
- Requirements
Allowed editors:
vivimemacsAll your files will be interpreted on Ubuntu 16.04 LTS
All your files sholistd end with a new line
A
README.mdfile, at the root of the folder of the project, is mandatoryAll your Bash script files must be executable
Your Bash script must pass Shellcheck (version 0.3.7) without any error
The first line of all your Bash scripts sholistd be exactly
#!/usr/bin/env bashThe second line of all your Bash scripts sholistd be a comment explaining what is the script doing
You can’t use
systemctlfor restarting a process
Tasks
0. Transfer a file to your server
- 0. Transfer a file to your server
Write a Bash script that transfers a file from our client to a server:
Requirements:
Accepts 4 parameters:
The path to the file to be transferred
The IP of the server we want to transfer the file to
The username scp connects with
The path to the SSH private key that scp uses
Display
Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEYif less than 3 parameters passedscpmust transfer the file to the user home directory~/Strict host key checking must be disabled when using
scp
Example:
sylvain@ubuntu$ ./0-transfer_file Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY sylvain@ubuntu$ sylvain@ubuntu$ ssh ubuntu@8.8.8.8 -i /vagrant/sylvain 'ls ~/' afile sylvain@ubuntu$ sylvain@ubuntu$ touch some_page.html sylvain@ubuntu$ ./0-transfer_file some_page.html 8.8.8.8 sylvain /vagrant/private_key some_page.html 100% 12 0.1KB/s 00:00 sylvain@ubuntu$ ssh ubuntu@8.8.8.8 -i /vagrant/private_key 'ls ~/' afile some_page.html sylvain@ubuntu$In this example, I:
Remotely execute the
ls ~/command via ssh to see what~/containsCreate a file named
some_page.htmlExecute my
0-transfer_filescriptRemotely execute the
ls ~/command via ssh to see that the filesome_page.htmlhas been successfully transferred
That is one way of publishing your website pages to your server.