SSD Nodes Learn Hosting plans →
How to do am Matt ConnorBy Matt Connor

HTTP Explained for Server Admins: Methods and Status Codes

Learn HTTP from server side: understand GET, status codes, headers, nginx logs, caching, and where TLS and HTTP/3 fit into each request.

Wetin be HTTP?

HTTP (hypertext transfer protocol) na set of rules wey client and web server dey use to request something and send am back. Client dey send request: method like GET, path like /pricing, protocol version, list of headers, and sometimes body. Server dey answer with status code like 200, followed by e own headers and usually body. Every page view and every API (application programming interface) call for your server na this same exchange wey dey repeat.

HTTP no keep state by itself. Server no remember wetin you request one second ago, so anything wey behave like memory, like login session, dey carried inside header for every single request. This property explain plenty of wetin follow: caching depend completely on headers, and load balancer fit send your next request go different backend without causing problem.

Everything wey dey below show how this model look from server side, for your access log and inside your nginx config.

Raw request and response wey get annotation

Na complete HTTP/1.1 request be this. Blank line dey end the headers, and anything after that line na the body. Normally, GET no dey get body.

GET /pricing HTTP/1.1
Host: example.com
User-Agent: curl/8.5.0
Accept: */*
Accept-Encoding: gzip
  • GET na the method. E talk wetin you want make happen. GET reads, POST sends data, PUT replaces, DELETE removes, while HEAD asks for the headers of GET without the body.
  • /pricing na the path. Hostname no dey part of the request line, na why the next header dey exist.
  • HTTP/1.1 na the protocol version wey the client dey use.
  • Host: example.com names the site wey the client want. HTTP/1.1 require am, so nginx go answer request wey no get am with 400 Bad Request.
  • The remaining ones na preferences. Accept-Encoding: gzip talk say the client fit decompress, so server fit compress the body.

Response get the same shape, but e get status line for top.

HTTP/1.1 200 OK
Date: Thu, 06 Aug 2026 09:12:44 GMT
Server: nginx
Content-Type: text/html; charset=utf-8
Content-Length: 5310
Cache-Control: public, max-age=300

<!doctype html>...
  • 200 OK na the status code with the reason phrase. Na the code matter. The phrase na decoration, and clients dey ignore am.
  • Content-Type tells the client how e suppose treat the bytes wey follow.
  • Content-Length na the body size for bytes, so the client know where body dey end. When size no dey known ahead of time, server go send Transfer-Encoding: chunked instead and mark the end with chunk wey get zero length.
  • Cache-Control tells the browser and any cache for between how long dem fit treat this response as fresh. Once e pass max-age seconds, e don stale. This no mean say dem delete am: cache fit keep stale copy and revalidate am with your server instead of downloading the whole body again.
  • The blank line after headers dey separate dem from body for both directions.

Header names no dey case-sensitive, and every line dey end with carriage return followed by line feed, instead of bare newline. You no go type these by hand, but you go meet dem for packet capture.

To watch real request and response pair, run this against site wey you own:

curl -sS -o /dev/null -D - https://example.com/

-D - writes response headers to your terminal, while -o /dev/null throws the body away. Prefer this instead of curl -I, because -I sends a HEAD request. Application server wey dey handle HEAD differently from GET, as many dey do, go then show you headers wey no browser ever receive. curl -v prints both sides, with request lines marked > and response lines marked <.

Wetin the request line dey look like for your nginx access log

nginx ships with one combined log format, and na so dem define am:

log_format combined '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';

One line wey e produce:

203.0.113.45 - - [06/Aug/2026:09:12:44 +0000] "GET /pricing HTTP/1.1" 200 5310 "https://example.com/" "Mozilla/5.0 (X11; Linux x86_64) Chrome/127.0.0.0 Safari/537.36"
  • 203.0.113.45 na $remote_addr, the address wey open the TCP (transmission control protocol) connection. If proxy dey in front, na the proxy go show here, no be visitor, unless you don configure the realip module wey we explain further down to replace am.
  • The first - na fixed placeholder. The second one na $remote_user, and e only get value when HTTP basic authentication dey use.
  • "GET /pricing HTTP/1.1" na $request, the complete original request line. With nginx default log escaping, double quote, backslash, and any byte below 32 or above 126 go write as \xXX, so the line remain accurate, but e no always match byte for byte.
  • 200 na the status wey your server return, no be the status wey visitor see.
  • 5310 na $body_bytes_sent, the body only. Response headers no dey count, so this number always smaller than the bytes wey server actually send.
  • The last two quoted fields na Referer and User-Agent. Both come from client, so client fit put anything inside dem.

Junk too dey enter log, but e go dey escaped form. Client wey speak TLS (transport layer security) to your plaintext port 80 go leave one 400 line, and the request field go start with escaped bytes like "\x16\x03\x01\x02\x00\x01". \x16 na the TLS handshake record type, so those bytes na the beginning of one ClientHello, no be request line at all. Your server dey behave correctly. Something dey point HTTPS to HTTP port.

Add $server_protocol to your log format too. E go print HTTP/1.1, HTTP/2.0 or HTTP/3.0, and na the fastest way to confirm say protocol change really take effect.

Wetin common status codes mean when your own site returns dem

The first digit na the class, and na the class you suppose read first.

2xx mean say e work. 200 OK for normal read. 201 Created after POST wey create something. 204 No Content for success wey no get anything to send back, and na the usual answer to DELETE.

3xx mean say make you look somewhere else. 301 permanent, and browsers cache am well-well, sometimes until user clear their profile. So, 301 wey point to wrong hostname fit hard to undo. Use 302 while you still dey test redirect. 304 Not Modified na success, no be error: client send conditional request, either If-None-Match wey carry ETag (entity tag) wey you still recognise, or If-Modified-Since with date wey resource never change since. So you reply with headers and no body. If log full of 304s, e mean caching dey work.

4xx mean say request wrong. 400 Bad Request na malformed input. 401 Unauthorized really mean unauthenticated, and e must carry WWW-Authenticate header wey name the scheme. 403 Forbidden mean say server understand the request but still refuse am. 404 Not Found na path wey no exist, or path wey server prefer not to admit say e exist, because some applications return 404 instead of 403 to hide resource from clients wey no get access. 405 Method Not Allowed na correct path with wrong method, and na wetin POST to static file location returns. 413 na body wey bigger than nginx client_max_body_size, wey default to 1 megabyte. Error log go confirm am with client intended to send too large body.

A 403 for static file almost always mean filesystem problem, no be HTTP rule. Read /var/log/nginx/error.log before you change any config. open() "/srv/site/index.html" failed (13: Permission denied) mean nginx worker user no fit read the file, most times because parent directory no get execute permission for others. directory index of "/srv/site/" is forbidden mean path resolve to directory wey no get index file while autoindex dey off.

5xx mean say problem dey your side. 500 na general catch-all server error, and for your own site e usually point to unhandled error for your application. 502 Bad Gateway mean nginx no fit get usable response from upstream, and error log go name the cause: connect() failed (111: Connection refused) while connecting to upstream mean say nothing dey listen on address for proxy_pass. 504 Gateway Timeout mean nginx stop waiting for upstream. The usual case na upstream wey accept connection then no talk anything within proxy_read_timeout, wey default to 60 seconds. Log go record am as upstream timed out (110: Connection timed out) while reading response header from upstream. Connection attempt wey no complete within proxy_connect_timeout, wey also default to 60 seconds, go end with 504 too, and the log line go end with while connecting to upstream. 503 Service Unavailable mean server temporarily no fit handle request, usually because e overload or e dey down for scheduled maintenance. Note say nginx own rate limiter returns 503, because limit_req_status default to 503. If you dey search for 429 Too Many Requests for your log but you dey find 503 instead, na why be that. Set limit_req_status 429; to get the correct code.

The headers wey matter when you run the server

Host dey choose the site. One IP address fit serve hundreds of hostnames, and nginx dey match Host against server_name to decide which server block go answer. If nothing match, nginx dey use the default server. Na the first block wey dey listen on that address and port, unless another one get default_server. If new virtual host dey return the wrong site, na almost always because the name no match, so the request fall through to the default. Test am without touching DNS:

curl -sS -o /dev/null -D - -H 'Host: app.example.com' http://127.0.0.1/

User-Agent na self-description wey client write, and e fit contain any free text. Use am as hint when you dey read logs. Never use am as control, because any client wey wan lie about am go simply do am. So if you block scraper by User-Agent, you go only filter the polite ones.

Content-Type dey decide how to interpret the bytes: application/json for API request, text/html; charset=utf-8 for page. nginx dey map file extensions to types with /etc/nginx/mime.types, and the packaged nginx.conf dey set default_type application/octet-stream;. So, if file get extension wey nginx no know, nginx go offer am as download instead of rendering am. The visible sign na page wey load without styling while browser console dey print Refused to apply style from ... because its MIME type ('text/plain') is not a supported stylesheet MIME type. MIME here mean multipurpose internet mail extensions. Na the naming scheme wey those type strings come from.

Cache-Control na how you control every cache between your server and the reader. public, max-age=31536000, immutable good for assets wey filename contain content hash, because the name go change when the content change. no-store belong on anything wey specific to one user, because shared cache wey keep logged-in page fit hand am to the next person wey request the same URL. private na the middle setting: browser fit keep am, but shared cache no fit.

X-Forwarded-For dey exist because proxy dey hide visitor address. Once request pass through reverse proxy, $remote_addr na the proxy address. So your logs, geolocation, and rate limiting go see one client until you restore the original address. The proxy need pass the original address along:

proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

Then you need tell the receiving server to trust the forwarded address, and specify exactly who e suppose trust:

set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;

These two directives belong to nginx realip module. E replaces $remote_addr with the forwarded address and keeps the connection own address inside $realip_remote_addr. If you compile nginx yourself, add --with-http_realip_module, because module no dey built by default.

Only list ranges wey you control. X-Forwarded-For na plain text wey any client fit send, so set_real_ip_from 0.0.0.0/0; go allow visitor choose the address wey you log and the address wey your rate limiter count.

X-Forwarded-Proto dey prevent one specific and common failure. Your proxy dey terminate TLS and forward request to application over plain HTTP. Application see plain request, decide say visitor suppose use HTTPS, and answer 301 https://example.com/. Browser follow am, proxy terminate TLS again and forward plain HTTP again, and the loop continue until browser give up with ERR_TOO_MANY_REDIRECTS. Sending X-Forwarded-Proto: https tell application say visitor don already dey on HTTPS, so e stop redirecting.

HTTP/1.1 vs HTTP/2 vs HTTP/3: wetin change for you

HTTP/1.1 na text, and for practical use e dey handle one request at a time for each connection. Connection: keep-alive let the next request reuse the same TCP connection, so e save the setup cost, but responses still dey come back for the same order wey dem request. The protocol still allow pipelining, where client write several requests without waiting for answers, but the ordering rule still apply and no modern browser dey turn pipelining on by default. One slow response go block everything wey dey queue behind am. Na head-of-line blocking be this, and browsers dey avoid am by opening several connections to the same hostname at once.

HTTP/2 keep the same methods and status codes, but e change the framing to binary. Many requests fit share one connection as independent streams, and repeated header text dey compressed. This matter because modern request dey carry plenty header text. The connection still na TCP, so one lost packet go stall every stream for that connection until retransmission arrive. The head-of-line blocking no disappear. E move down from HTTP go the transport layer. Server push dey part of HTTP/2 before, but for practical use e don go, because Chrome remove support for am in 2022.

HTTP/3 keep the same semantics again and replace TCP with QUIC, wey be transport built on UDP (user datagram protocol). QUIC streams dey independent all the way down, so lost packet go stall only the stream wey the packet belong to. TLS 1.3 dey built inside the QUIC handshake instead of layering am on top, so new connection need fewer round trips. Two practical results follow: UDP port wey your server use for HTTP/3 must dey open for every firewall along the path, and any network wey dey throttle or block UDP go push clients back to HTTP/2. That port usually na 443, but the protocol allow server use any UDP port, because advertisement wey point browsers to HTTP/3 always name the port explicitly.

Wetin change for you, for concrete terms. Browsers usually no dey start with HTTP/3. Dem connect through HTTP/2 or HTTP/1.1, see an Alt-Svc: h3=":443"; ma=86400 header for the response, then use HTTP/3 for later connections to that host. The exception na HTTPS record for DNS wey get alpn value listing h3. This one let browser like Firefox open HTTP/3 for the first connection. That record na extra hint, no be replacement, so the header no be optional decoration. Na the main discovery mechanism be that. For nginx, HTTP/2 become its own directive for version 1.25.1 (http2 on; inside the server block, replacing the old listen ... http2 parameter), and QUIC enter mainline 1.25.0, where HTTP/3 site need listen 443 quic reuseport; together with the normal listen 443 ssl;. HTTP/3 module no dey built by default (--with-http_v3_module), and nginx documentation still call the support experimental.

Proxies no get the same level of maturity for this matter, so check am against the version wey you actually dey run. As of November 2026, Caddy dey serve HTTP/3 by default without configuration. nginx need the explicit quic listener plus the Alt-Svc header wey we describe above. Traefik enable am per entry point through an explicit http3 option. If you terminate TLS for Traefik wey dey in front of several Docker apps, na there dem decide the protocol version wey your visitors go get, and the hop from the proxy to your container usually na plain HTTP/1.1, no matter wetin browser negotiate.

Verify am instead of assuming. curl --http3 -sS -o /dev/null -D - https://example.com/ go work only if curl -V list HTTP3 among its features, and most distribution builds no include am. The dependable check na your own log: add $server_protocol to the format and read wetin real browsers negotiate. Before all that, confirm say UDP port wey your quic listener dey use, 443 for the config above, really dey open. Firewall wey allow TCP 443 only go make HTTP/3 fail quietly while the site continue to work over HTTP/2. Knowing which ports dey open and listening for your Linux server na the first thing to check.

HTTPS: HTTP na protocol, TLS na wrapper

HTTPS no be separate protocol. Na the same requests and status codes wey dey pass inside TLS session. Port 80 dey carry dem without encryption, while port 443 dey carry dem encrypted. TLS handshake go complete first, then HTTP request go travel inside the encrypted channel. Na why certificate problem no dey get status code: the failure happen before any HTTP byte send, so no response dey to number.

One ordering detail important for server wey dey host many sites. Server dey choose certificate with SNI (server name indication), wey be field for TLS handshake wey carry hostname in clear before any HTTP header exist. So server first choose certificate from SNI, then choose virtual host from the Host header. Na two separate lookups wey normally dey agree. When dem no agree, browser go show name mismatch like NET::ERR_CERT_COMMON_NAME_INVALID and e no go send any request, because default server certificate offer for name wey e no cover.

For public site, get real certificate and make e renew by itself. Certbot with Let's Encrypt for nginx dey write certificate paths inside your server block and install renewal timer for you. For hostname wey no public authority fit validate, like internal name or bare IP address for your own network, self-signed certificate for Ubuntu na the honest option, as long as you accept say every client must be told to trust am.

Once TLS dey work, send everything for port 80 go port 443:

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

Add Strict-Transport-Security only when you sure. The add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always; header tells browsers make dem refuse plain HTTP for that hostname for two years, and dem dey obey am from their own cache. This means say removing the header later no go undo am. Start with max-age of few hours, confirm say every subdomain really dey on HTTPS, then increase am.

FAQ

Wetin be di difference between HTTP and HTTPS?

HTTPS na HTTP wey dey pass inside TLS (transport layer security) session. Di methods and status codes dey the same. Wetin change be say TLS encrypts di bytes between di client and anything wey terminate TLS, and di default port move from 80 go 443. Because TLS handshake dey finish before di first HTTP byte send, certificate failure no dey produce status code. Na why browser certificate warning dey show error name like NET::ERR_CERT_COMMON_NAME_INVALID instead of number like 403.

Why my site dey return 502 Bad Gateway?

502 from nginx mean say nginx no fit get useful response from di upstream wey e dey proxy to. So visitor request dey okay, but something behind nginx no dey okay. Read /var/log/nginx/error.log. connect() failed (111: Connection refused) while connecting to upstream mean say nothing dey listen for di address and port inside proxy_pass. Check say di application dey run and e bind for di place wey you expect. no live upstreams while connecting to upstream mean say every server for di upstream block don mark as down after repeated failures. Compare am with 504 Gateway Timeout. E mean say nginx timeout while e dey wait for di upstream, either for connection to complete within proxy_connect_timeout or for response within proxy_read_timeout.

Why my access log dey show di same IP address for every visitor?

Because $remote_addr dey record di address wey open di TCP connection. Behind reverse proxy or content delivery network, na di proxy address e go record. Visitor address dey come inside X-Forwarded-For header instead. Set proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; for di proxy. Then for di receiving nginx, set set_real_ip_from to di proxy address range and real_ip_header X-Forwarded-For;. List only ranges wey you control. Any client fit send that header as text. If you trust am from di whole internet, visitor fit choose di address wey you log and di address wey you rate limit.

I need turn on HTTP/2 or HTTP/3?

HTTP/2 worth turning on because na one directive for site wey already get TLS, and e remove per-connection request limit wey dey make page with plenty small files slow. HTTP/3 get smaller and less certain benefit. E also need open UDP port, normally 443, plus proxy build wey get QUIC support. Remember say browsers normally switch to HTTP/3 only after dem see Alt-Svc header for earlier response, or HTTPS DNS record wey list h3. Without one of those, nothing go change no matter wetin your listen line talk. Add $server_protocol to your log format and measure wetin visitors actually negotiate before you spend time on am.

Wetin 403 Forbidden mean when di file dey exist?

For static site, 403 usually mean filesystem permission problem, no be HTTP rule. open() ... failed (13: Permission denied) inside /var/log/nginx/error.log mean nginx worker user no fit read di file. Most times, na because parent directory no get execute permission for others, no be because di file mode dey wrong. directory index of ... is forbidden mean di request resolve to directory wey no get index file while autoindex dey off. Explicit deny rule inside di matching location block fit also return 403. So read that block when error log no show anything.

Dis article help you?

#http#https#web-server#headers#http3