Objective: Install, configure and run a basic HTTP web server with Nginx, and open your firewall so your laptop can reach it. Then use
digto see how your server turns a name into an IP address with DNS.
In Lab 12 you used curl to fetch pages from web servers on the internet, and ss to see which programs were listening on your server. In this lab your development server becomes a web server. You install Nginx (pronounced "engine x"), replace its configuration and its home page with your own, and view your page from a browser on your laptop.
In Lab 9 you set a DNS server for your development server, and in Lab 12 you saw that ping pce.uw.edu can't work if your server can't look up the name, even when the network is fine. In the second half of this lab you ask DNS servers questions directly.
This lab covers plain HTTP. You add HTTPS to the same web server in Lab 17.
Note: This lab is done on your development server, NOT your production server. Connect with SSH from Terminal or PuTTY and log in as your own user. A few steps also use a browser or a command on your laptop.
Some steps give you every command. Others give you a Goal and ask you to work out the commands yourself. If you get stuck, open the hint. Once you have an answer, or if you are really stuck, open the solution and compare it with your own.
If you get stuck, check the Troubleshooting section at the end of this lab.
The examples in this lab come from a UTM server, so they use 192.168.64.7. Always use your values. Your Nginx version and some of the addresses in the output may also be different.
A web server is a program that waits for requests, usually on port 80 for HTTP, and answers with files such as web pages. Nginx is a popular, lightweight web server. We can install it with dnf:
sudo dnf install -y nginx
Installing a service doesn't start it. Use systemctl, as you did for sshd and NetworkManager, to start it now and to start it after every reboot:
sudo systemctl enable nginx
sudo systemctl start nginx
systemctl status nginx
| Command | What it does |
|---|---|
sudo systemctl enable nginx |
Starts Nginx automatically after each reboot. It doesn't start it now. |
sudo systemctl start nginx |
Starts Nginx now. It doesn't change what happens after a reboot. |
systemctl status nginx |
Shows enabled and active (running) if both worked. Press q to quit if it opens a pager. |
Now send your web server a request. Your server can reach itself as localhost or 127.0.0.1, as you saw in Lab 9:
curl http://localhost
curl http://127.0.0.1
Both print the same long page of HTML, the Nginx test page. curl -I, from Lab 12, asks for only the headers, the short note the web server sends before the page:
curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Sat, 31 Oct 2026 20:15:06 GMT
Content-Type: text/html
| You see | It means |
|---|---|
HTTP/1.1 200 OK |
The status code. 200 means the request worked. |
Server: nginx/1.20.1 |
The web server program and its version. |
Content-Type: text/html |
The kind of file being sent, here a web page. |
Goal: Use a command from Lab 12 to show that Nginx is listening, and on which port. Which addresses is it listening on?
ss.sudo shows you the name of the program.grep to keep only the lines you want.sudo ss -tlnp | grep nginx
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=2212,fd=6),("nginx",pid=2211,fd=6),("nginx",pid=2210,fd=6))
LISTEN 0 511 [::]:80 [::]:* users:(("nginx",pid=2212,fd=7),("nginx",pid=2211,fd=7),("nginx",pid=2210,fd=7))
Nginx is listening on port 80, on 0.0.0.0 (every IPv4 address on the server) and [::] (every IPv6 address). The three process IDs are one main process and two workers, one worker for each CPU.
Nginx reads its settings from /etc/nginx/nginx.conf. The default file works, but it is longer than you need. In this part you replace it with a short file you can read line by line.
Look at the original first. Press q to leave less:
cd /etc/nginx
ls
less nginx.conf
Goal: Without scrolling through the file, find the line that sets the port Nginx listens on, and the line that sets the directory its pages come from. That directory is called the web root.
grep -n from Lab 2 prints matching lines with their line numbers.listen and root.grep -n listen nginx.conf
grep -n root nginx.conf
Some matches start with #. These are comments, and Nginx ignores them. The active lines are listen 80; and root /usr/share/nginx/html;. There is also a listen [::]:80; line, which is why you saw [::]:80 in Task 1.
Keep the original as a backup. The .orig ending is only a reminder to you that it is the original file:
sudo mv nginx.conf nginx.conf.orig
sudo vim nginx.conf
Paste in this configuration, then save and quit with :wq:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
access_log /var/log/nginx/access.log;
server {
listen 80;
server_name itfdn.uw.edu;
root /usr/share/nginx/html;
location / {
}
}
}
| Line | What it does |
|---|---|
user nginx; |
Nginx starts as root so it can use port 80, but its workers run as the less powerful user nginx. |
worker_processes 1; |
Start one worker process. The default file uses auto, one for each CPU. |
error_log, access_log |
Where Nginx writes its problems, and a line for each request. You read both logs later in this lab. |
pid /run/nginx.pid; |
The file that records the main process ID, so systemctl can find it. |
events { ... } |
Connection settings. Each worker can handle up to 1024 connections. |
http { ... } |
Settings for web traffic. |
server { ... } |
One web site. A server can run many. |
listen 80; |
Answer on port 80, on IPv4 only. You removed the [::]:80 line. |
server_name itfdn.uw.edu; |
The name of this site. Because this is the only server block, it answers every request, whatever name was used. |
root /usr/share/nginx/html; |
The web root: where to look for the files. |
location / { } |
Rules for the paths under /. It is empty, so the defaults apply. |
Each setting ends with a semicolon, and each { needs a matching }.
Check that both files are there:
ls -l /etc/nginx/nginx.conf*
Saving the file doesn't change the running web server. Nginx read its settings when it started, and it won't read them again until you tell it to. Test the new file first, the same idea as sshd -t in Lab 7:
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Now tell Nginx to use it, and check that it still answers:
sudo systemctl reload nginx
curl -I http://localhost
sudo ss -tlnp | grep nginx
| Command | What it does |
|---|---|
sudo nginx -t |
Tests the configuration, then exits. |
sudo systemctl reload nginx |
Rereads the configuration without stopping the web server. Nginx keeps the old settings if the new file has an error. |
sudo ss -tlnp | grep nginx |
Now shows one main process, one worker, and only 0.0.0.0:80, matching your new file. |
Question: How do you think you get help for the
nginxcommand? How would you print the whole configuration that Nginx sees?
nginx -h lists the options, and man nginx gives more detail. sudo nginx -T, with a capital T, tests the configuration and also prints it.
Every administrator mistypes a configuration file sooner or later. It helps to know what the error looks like.
Goal: Delete the semicolon at the end of the worker_connections line. Test the file, and find the problem from the error message. Is your web server still running? Then fix the file, and test it again.
sudo vim /etc/nginx/nginx.conf. Lab 4 covers x, which deletes one character.nginx -t names the file and the line number. cat -n prints a file with line numbers.curl -I http://localhost shows whether the server still answers.After deleting the semicolon:
sudo nginx -t
nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:8
nginx: configuration file /etc/nginx/nginx.conf test failed
cat -n /etc/nginx/nginx.conf | head -n 9
curl -I http://localhost
The message names line 8, the }, but the mistake is on line 7. Nginx only noticed the missing semicolon when it reached something unexpected. Check the line above when an error doesn't seem to make sense.
curl still gets 200 OK. The running web server doesn't read the file until you reload it, which is why you test first.
Put the semicolon back, then run sudo nginx -t again. Run sudo systemctl reload nginx if you want to be sure that the fixed file is the one in use.
When a request doesn't name a page, as in http://localhost, Nginx looks in the web root for a file called index.html. Move the default one out of the way, and see what happens:
cd /usr/share/nginx/html
ls
sudo mv index.html index.html.orig
curl -I http://localhost
HTTP/1.1 403 Forbidden
Server: nginx/1.20.1
Date: Wed, 28 Oct 2026 20:02:28 GMT
Content-Type: text/html
Content-Length: 153
Connection: keep-alive
The web server is running, but it has nothing it is willing to send. Without an index.html, Nginx could list the directory, but it doesn't do that by default. The error log gives the reason:
sudo tail -n 1 /var/log/nginx/error.log
... [error] 2340#2340: *5 directory index of "/usr/share/nginx/html/" is forbidden, client: 127.0.0.1, ...
The old page is still there. Ask for it by name.
curl -I http://localhost/index.html.orig
The number on the first line of each answer tells you what happened. The first digit gives the kind of answer:
| Code | Name | It means |
|---|---|---|
200 |
OK | Here is what you asked for. |
301, 302 |
Redirect | It is somewhere else, as you saw with www.uw.edu in Lab 12. |
403 |
Forbidden | The web server understood, but won't send it. |
404 |
Not Found | There is no such file. |
500, 502 |
Server error | Something went wrong on the web server's side. |
Create a new index.html:
sudo vim index.html
Question: Do you need
sudohere? How can you tell if your user can write to/usr/share/nginx/html?
Yes. ls -ld /usr/share/nginx/html shows the owner root with rwxr-xr-x, so only root can create files there. You are in "other", which has no w. See Lab 6. Everyone can read the directory, which is how the nginx user reads your page.
Paste in this HTML, then save and quit:
<html>
<head>
<title>ITFDN 140 Development Server</title>
</head>
<body>
Home page for my ITFDN 140 development server.
</body>
</html>
You don't need to reload Nginx for a new page. It reads the page from the disk for each request, and only configuration changes need a reload.
curl -I http://localhost
curl http://localhost
You should see your own HTML, and no 403 error.
Goal: Add a page called about.html with a line or two of your own, and fetch it with curl. Then ask for a page that doesn't exist. What status code do you get? Why isn't it 403 this time?
index.html.index.html.orig.curl -I shows you the status code.First create the new html page.
sudo vim /usr/share/nginx/html/about.html
Next test it and the non-existent page.
curl -I http://localhost/about.html
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Wed, 28 Oct 2026 20:10:43 GMT
Content-Type: text/html
Content-Length: 25
Last-Modified: Wed, 28 Oct 2026 20:09:35 GMT
Connection: keep-alive
ETag: "6ae2567f-19"
Accept-Ranges: bytes
curl http://localhost/about.html
This is a UW PCE course.
curl -I http://localhost/nosuchpage.html
HTTP/1.1 404 Not Found
Server: nginx/1.20.1
Date: Wed, 28 Oct 2026 20:10:54 GMT
Content-Type: text/html
Content-Length: 153
Connection: keep-alive
404 means there is no such file. The 403 came from asking for a directory, which exists, that Nginx wouldn't list.
So far every request has come from the server itself. Now try from your laptop. You need your server's address, and VirtualBox users also need one more port forwarding rule.
| Hypervisor | Do this first | Address for your browser |
|---|---|---|
| UTM (Mac) | Nothing. Your Mac can reach your server directly. | http://192.168.64.3, using your IP address |
| VirtualBox (Windows) | Add a rule, as you did for SSH in Lab 1: VM Settings, Network, Port Forwarding. Name http, protocol tcp, host port 8000, guest port 80. Leave the IP fields blank. | http://127.0.0.1:8000 |
Type the address discovered on your development server that aligns with the column Address for your browser, with http://, into a browser on your laptop. It should fail, and the page should time out or say it can't connect. Your server is running, but it is the firewall that is blocking the traffic. The firewall doesn't apply to traffic from the server to itself, which is why curl worked.
RHEL 9 only allows a few kinds of inbound traffic by default. Look at the firewall, then allow HTTP.
Note: We will cover firewalls in more detail later.
systemctl status firewalld
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --zone=public --list-services
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
sudo firewall-cmd --zone=public --list-services
The two --list-services commands show the change. http is new in the second one:
cockpit dhcpv6-client ssh
cockpit dhcpv6-client http ssh
| Command | What it does |
|---|---|
systemctl status firewalld |
Checks that the firewall is running. |
--get-active-zones |
Shows the zone, a named set of rules, your interface is in. Yours is public. |
--list-services |
Shows what the zone allows in. |
--permanent --add-service=http |
Adds HTTP (TCP port 80) to the saved rules. |
--reload |
Makes the saved rules active. |
Common Pitfall:
--permanentonly changes the saved rules. They aren't active until you run--reload.
Refresh your browser. You should now see your page.
Note: Your browser may mark the page Not secure. That is correct: this is plain HTTP, so nothing is encrypted. You fix this in a later lab. Also some browsers will block http traffic, if you notice this on your mac be sure to try Safari as the default often allows http traffic.
Nginx writes a line in its access log for every request.
Goal: Find the request from your browser in the access log. Which IP address did it come from, and why that address? What else did your browser ask for, that you didn't?
nginx.conf, on the access_log line.tail from Lab 2 shows the end of a file. You need sudo.sudo tail -n 5 /var/log/nginx/access.log
192.168.64.1 - - [31/Oct/2026:13:20:01 -0700] "GET / HTTP/1.1" 200 180 "-" "Mozilla/5.0 ..."
192.168.64.1 - - [31/Oct/2026:13:20:01 -0700] "GET /favicon.ico HTTP/1.1" 404 153 "http://192.168.64.7/" "Mozilla/5.0 ..."
| Part | It means |
|---|---|
192.168.64.1 |
Where the request came from: your hypervisor's address, 10.0.2.2 on VirtualBox, the same as your SSH session in Lab 12. |
GET / |
The request. GET means "send me this". / means the home page. |
200, 404 |
The status code, then the size of the answer in bytes. |
Mozilla/5.0 ... |
The browser that made the request. |
Browsers ask for /favicon.ico, the small icon for the tab, on their own. You don't have one, so it gets a 404. That is harmless. You may not see this line if your browser remembers an earlier answer.
Going further: run sudo tail -f /var/log/nginx/access.log, and refresh your browser. Press Ctrl+C to stop.
You typed an address in Part 4, but people use names. DNS, the Domain Name System, is the system of servers that turns a name such as www.washington.edu into an IP address. In Lab 12 you saw that it uses port 53.
A program on your server that needs an address checks two places, in this order:
| Order | Where | What it is |
|---|---|---|
| 1 | /etc/hosts |
A short list of names and addresses on this server only. |
| 2 | /etc/resolv.conf |
The DNS servers to ask, from your settings in Lab 9. |
Look at both. This is how your server knows that localhost means 127.0.0.1. The order comes from the hosts line in a third file, where files means /etc/hosts:
cat /etc/hosts
cat /etc/resolv.conf
grep ^hosts /etc/nsswitch.conf
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# Generated by NetworkManager
search localdomain
nameserver 192.168.64.1
nameserver 8.8.8.8
hosts: files dns myhostname
dig asks DNS servers questions, and shows you the whole answer. It isn't installed yet. Its package has a different name, bind-utils. BIND is a widely used DNS server program:
dig
sudo dnf install -y bind-utils
dig -v
dig www.washington.edu
; <<>> DiG 9.16.23-RH <<>> www.washington.edu
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15993
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;www.washington.edu. IN A
;; ANSWER SECTION:
www.washington.edu. 598 IN CNAME www-uw.umslb.s.uw.edu.
www-uw.umslb.s.uw.edu. 28 IN A 128.208.60.208
www-uw.umslb.s.uw.edu. 28 IN A 34.82.219.4
www-uw.umslb.s.uw.edu. 28 IN A 34.168.51.100
www-uw.umslb.s.uw.edu. 28 IN A 128.208.60.183
;; Query time: 16 msec
;; SERVER: 192.168.64.1#53(192.168.64.1)
;; WHEN: Sat Oct 31 13:16:52 PDT 2026
;; MSG SIZE rcvd: 143
| You see | It means |
|---|---|
status: NOERROR |
The DNS server answered the question. |
QUESTION SECTION |
What you asked. A means "the IPv4 address of this name". |
ANSWER SECTION |
The answer. Each line is one record. |
598, 28 |
The TTL: how many seconds a DNS server may remember this record. This isn't the same TTL as ping in Lab 12. |
CNAME |
This name is another name for www-uw.umslb.s.uw.edu, so look that up instead. |
A |
An IPv4 address. A busy site can have several, to share the load. |
SERVER |
The DNS server that answered, and its port. It should be the first nameserver in your /etc/resolv.conf. |
For just the answer, add +short:
dig +short www.washington.edu
Tip: Your answers can be different from the example, and from your classmates'. Large sites give out different addresses over time.
dops.ulcert.uw.edu is a real web site on the UW network, with its own records in DNS. /etc/hosts is checked first, so you can use it to send that name to your own web server instead.
Goal: Use curl -I and dig to see what dops.ulcert.uw.edu is now. Then add a line to /etc/hosts so that the name means 127.0.0.1 on your server, and use curl to show that you get your own page, not the real site. What does dig say now? Why? Would your laptop see the change? Remove your line when you are finished.
Warning: Add one new line at the end of
/etc/hosts. Leave the localhost lines alone.
curl -I answer, so you can tell the real site from yours./etc/hosts is an address, then the name.dig only talks to DNS servers. getent ahosts dops.ulcert.uw.edu looks a name up the way other programs do.Before you change anything:
curl -I http://dops.ulcert.uw.edu
dig +short dops.ulcert.uw.edu
HTTP/1.1 301 Moved Permanently
Server: nginx/1.14.1
Location: https://dops.ulcert.uw.edu/
140.142.159.189
The real site answers with a 301 redirect to HTTPS. Now edit the file:
sudo vim /etc/hosts
Add this line at the end:
127.0.0.1 dops.ulcert.uw.edu
curl http://dops.ulcert.uw.edu
dig +short dops.ulcert.uw.edu
getent ahosts dops.ulcert.uw.edu
| Command | Result | Why |
|---|---|---|
curl http://dops.ulcert.uw.edu |
Your own page | curl checks /etc/hosts first. Your server block answers every name, so it answers this one too. |
dig +short dops.ulcert.uw.edu |
Still the real address, 140.142.159.189 | dig skips /etc/hosts, and asks DNS. |
getent ahosts dops.ulcert.uw.edu |
127.0.0.1, on three lines | getent looks names up the way curl does. |
This is worth remembering. If dig and a program disagree about a name, check /etc/hosts. Administrators also use this file to test a new web site before changing its DNS records.
Your laptop wouldn't see the change. /etc/hosts only affects the server it is on, and nothing changed in DNS. The real site is still there for everyone else.
Now remove your line with sudo vim /etc/hosts, and check that curl -I http://dops.ulcert.uw.edu gets the 301 again.
An address is only one kind of record. Add a record type to the end of a dig command to ask for another one:
| Type | Question it answers | Example |
|---|---|---|
A |
What is the IPv4 address? (the default) | dig www.washington.edu |
AAAA |
What is the IPv6 address? | dig www.google.com aaaa |
CNAME |
What other name does this name stand for? | dig www.washington.edu cname |
NS |
Which DNS servers are in charge of this domain? | dig uw.edu ns |
MX |
Which servers receive email for this domain? | dig uw.edu mx |
PTR |
What name goes with this address? (a reverse lookup, with -x) |
dig -x 8.8.8.8 |
Try NS. These are the DNS servers that hold the records for uw.edu:
dig +short uw.edu ns
holly.s.uw.edu.
marge.cac.washington.edu.
hanna.cac.washington.edu.
Note: The dot at the end is the top of the DNS tree, called the root. A full name is read right to left: root, then edu, then uw, then holly.
Goal: Find the servers that receive email for uw.edu. Then find the name that goes with the address 140.142.159.151. What is the number in front of each mail server?
MX, and the reverse lookup uses -x.+short to keep the answers short.dig +short uw.edu mx
dig +short -x 140.142.159.151
100 mxa-00641c01.gslb.pphosted.com.
100 mxb-00641c01.gslb.pphosted.com.
ul-srv1.ulcert.uw.edu.
The number is the priority. Mail goes to the lowest number first. When two are equal, as here, mail is shared between them. Notice that UW's mail servers don't have to be inside uw.edu.
How does a DNS server find an answer it doesn't already have? +trace makes dig take each step itself, starting from the top of the tree:
dig uw.edu +trace | less
| Step | Who answers | What it says |
|---|---|---|
| 1 | Your DNS server | Here is the list of root servers. |
| 2 | A root server | I don't know uw.edu. Ask these edu servers. |
| 3 | An edu server | Ask these uw.edu servers. |
| 4 | A uw.edu server | Here is the answer. These are my records. |
DNS servers do one or both of two jobs:
| Kind of DNS server | What it does | Example |
|---|---|---|
| Recursive | Finds the answer to any question for you, following the steps above, and remembers it for the TTL. | Your nameserver lines |
| Authoritative | Holds the records for its own domain, and answers only for those. | hanna.cac.washington.edu, for uw.edu |
140.142.159.151 is one of the class DNS servers. It is authoritative for ulcert.uw.edu, the same domain as your production server, and it is recursive only for computers on the UW network and the class production servers. Your development server runs on your laptop, so it doesn't have a UW address. To the class server, it is just another computer on the internet. dig @server asks one particular server, and doesn't change any settings. Ask it about its own domain, then ask your usual DNS server:
dig @140.142.159.151 www.ulcert.uw.edu
dig www.ulcert.uw.edu
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 7, ADDITIONAL: 5
;; WARNING: recursion requested but not available
...
www.ulcert.uw.edu. 604800 IN A 140.142.159.151
...
;; SERVER: 140.142.159.151#53(140.142.159.151)
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
...
www.ulcert.uw.edu. 604800 IN A 140.142.159.151
...
;; SERVER: 192.168.64.1#53(192.168.64.1)
Both give the same address. The flags line shows the difference:
| Flag | It means |
|---|---|
aa |
Authoritative answer. This server holds the record itself. |
ra |
Recursion available. This server will go and find answers for you. |
rd |
Recursion desired. dig asked for that help. |
The class server shows you aa and no ra, because it won't do recursion for your address. Your usual server has ra and no aa, because it got the answer from somewhere else. Now ask the class server about a name that isn't in its domain:
dig @140.142.159.151 www.washington.edu
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 53938
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
REFUSED, with no answer section. The server is working correctly: this isn't its domain, and your address isn't one it looks names up for. DNS servers that are open to everyone can be misused in attacks, so administrators often limit recursion to their own networks.
Your server uses the first nameserver in /etc/resolv.conf. It only moves on to the next if the first one doesn't help. Put the class server at the top for a few minutes:
sudo vim /etc/resolv.conf
Add this line above the other nameserver lines:
nameserver 140.142.159.151

Your file also lists 8.8.8.8, from Lab 9, so it won't match this screenshot exactly.
Warning: This is a temporary change. The first line of this file says it is generated by NetworkManager, and NetworkManager will replace your edit. The lasting way to change DNS is
ipv4.dns, as in Lab 9.
Goal: With the class server first in /etc/resolv.conf, run dig with no @ for www.ulcert.uw.edu and for www.washington.edu. Check the status and SERVER lines. Then look up www.washington.edu with getent ahosts. Did your server lose the ability to find names outside ulcert.uw.edu?
dig www.ulcert.uw.edu | grep "status\|SERVER" shows only the two lines you want. The \| inside the quotes means "or".getent ahosts from Task 6 looks names up the way other programs do.dig www.ulcert.uw.edu | grep "status\|SERVER"
dig www.washington.edu | grep "status\|SERVER"
getent ahosts www.washington.edu | head -n 3
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8836
;; SERVER: 140.142.159.151#53(140.142.159.151)
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 37257
;; SERVER: 140.142.159.151#53(140.142.159.151)
128.208.60.208 STREAM www-uw.umslb.s.uw.edu
128.208.60.208 DGRAM
128.208.60.208 RAW
dig only asks the first server, and shows you exactly what it said, even REFUSED. Other programs still work, because when the first nameserver refuses, the system moves on to the next line in /etc/resolv.conf. That is why dig is useful for troubleshooting: it doesn't hide what one server said.
Restart NetworkManager, so it writes the file again from your Lab 9 settings. Your SSH session stays connected. Then check that 140.142.159.151 is gone, and that dig is back to your usual DNS server:
sudo systemctl restart NetworkManager
cat /etc/resolv.conf
dig www.washington.edu | grep "status\|SERVER"
You have now:
nginx -t and systemctl reload./etc/hosts and /etc/resolv.conf to see how a name becomes an address.dig to read DNS answers, to ask for different record types, and to compare recursive and authoritative DNS servers.Your development server keeps Nginx, your configuration, your pages and the firewall rule. You use them again when you add HTTPS in Lab 17.
systemctl enable and systemctl start? Which one would you notice was missing only after a reboot?nginx.conf and nothing changes. What did you forget? What should you run first?curl http://localhost works on your server, but your laptop's browser can't connect. Name two places you would check.curl reaches a different server than dig says a name points to. What file would you check?Q. systemctl status nginx says "failed", or start gives an error.
A. Run sudo nginx -t to check the configuration. If it passes, run sudo journalctl -u nginx | tail to see the reason. If something else is using port 80, sudo ss -tlnp | grep :80 shows you what.
Q. nginx -t says "unexpected", "not terminated by", or "unexpected end of file".
A. A semicolon or a } is missing. Look at the line it names, and the line above it. Compare your file with the one in Part 2. A paste can lose the first or last few characters of a file.
Q. I changed nginx.conf, but nothing changed.
A. Nginx hasn't read it yet. Run sudo nginx -t, then sudo systemctl reload nginx.
Q. curl http://localhost says "Connection refused".
A. Nginx isn't running. Check with systemctl status nginx, and start it with sudo systemctl start nginx.
Q. I still get "403 Forbidden" after creating my page.
A. Check the file's name and location with ls -l /usr/share/nginx/html. It must be exactly index.html. Then read the reason with sudo tail -n 1 /var/log/nginx/error.log. If you made the file in your home directory and moved it there with mv, it says Permission denied. The file kept a security label from your home directory. Fix it with sudo restorecon -v /usr/share/nginx/html/index.html. You learn about these labels in Lab 16.
Q. My browser can't reach my page, but curl http://localhost works.
A. Check these in order:
sudo firewall-cmd --zone=public --list-services and look for http. If you only see it with --permanent, you forgot --reload.ip -br address. Include http:// in the browser, as some browsers try HTTPS first.http://127.0.0.1:8000.Q. dig says "command not found".
A. Install it with sudo dnf install -y bind-utils.
Q. dig says "connection timed out; no servers could be reached".
A. dig can't reach the DNS server. Check that you still have a network with ping -c 3 8.8.8.8, then check the nameserver lines in /etc/resolv.conf. Some networks, including some guest Wi-Fi, also block DNS to servers outside their own network, which can affect @140.142.159.151 and +trace.
Q. dig says status: REFUSED.
A. If you asked the class server for a name outside ulcert.uw.edu, that is correct. Your development server doesn't have a UW address, so the class server won't look the name up for it. If you see it on every dig, 140.142.159.151 is still first in /etc/resolv.conf. Run sudo systemctl restart NetworkManager to put the file back.
Q. My edit to /etc/resolv.conf disappeared.
A. NetworkManager wrote the file again, as the first line of the file warns. Add the line again if you are still doing Part 7.
Q. curl http://dops.ulcert.uw.edu still shows my page after the lab.
A. Your line is still in /etc/hosts. Remove it with sudo vim /etc/hosts.
If you can't solve a problem, post it in this week's Teams channel, or reach out by email for help.
Lab complete