csot/contest

Task 08 — nginx reverse-proxy with X-Powered-By header

Submit one nginx server { … } block that reverse-proxies HTTP traffic and adds X-Powered-By: csot on responses.

Submit as

08.conf — a single server { … } block (not a full nginx.conf).

Input

Source Format
File Plain text nginx configuration snippet
Grader wrap Your block is inserted inside a minimal http { } context before nginx -t runs

Output

Stream Format
Runtime Not started in the grader
Grader result Pass if syntax is valid and required directives are present

Required directives inside server { }

Directive Requirement
proxy_pass Must proxy to an http://… upstream
add_header Must include X-Powered-By with value csot (always recommended)

Example

server {
    listen 80;
    server_name _;

    add_header X-Powered-By "csot" always;

    location / {
        proxy_pass http://127.0.0.1:9000;
        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

What the grader checks

Wraps your file as:

events {}
http {
    <your 08.conf>
}

Then:

  • nginx -t exits 0 (no syntax errors)
  • add_header X-Powered-By "csot" — spaces or tabs between tokens; " or ' quotes OK; always optional
  • proxy_pass http://… or https://… upstream
  • grep finds proxy_pass http://

Hints

  • Submit only a server { … } block — no extra http { } wrapper and no trailing } after the block
  • nginx -t -c /path/to/test.conf — validate without starting (use a wrapper config with error_log under /tmp; see sample solution)
  • add_header … always; — header on error responses too

Common mistakes

Mistake Symptom
Extra } after server { } unexpected "}" in grader log
Full nginx.conf with http { } around server Duplicate http / brace mismatch (grader already wraps your file in http { })
include /etc/nginx/... Permission errors or wrong paths in sandbox

Points: 5

Other tasks