FAQ: common Nginx & Apache errors

Short, direct answers to the errors people hit most when setting up a reverse proxy, HTTPS or redirects. Each one links to the generator option that fixes it.

Last updated 12 November 2026 · New to ProxyForge? Start with the how-to guide.

Why does nginx -t say unknown directive "http2"?

Your Nginx is older than 1.25.1. The separate http2 on; line only exists from 1.25.1 onward; older versions (for example 1.24 on Ubuntu 24.04, 1.22 on Debian 12, 1.18 on Ubuntu 22.04 and 1.20 on AlmaLinux 9) turn HTTP/2 on in the listen line instead:

listen 443 ssl http2;

Check your version with nginx -v. If it's below 1.25.1, tick Older Nginx (before 1.25.1) in the Config Generator or SSL Generator.

Full guide with tested fixes →

Why does nginx -t say "server" directive is not allowed here?

The server block is in the wrong place. Nginx only accepts server inside the http block, and files in /etc/nginx/conf.d/ and /etc/nginx/sites-enabled/ are already read inside http. So a site file holds server blocks (plus map or upstream) and nothing around them: no http { } wrapper, no events, no user lines. Don't paste it at the end of nginx.conf; save it as its own file in conf.d (RHEL, nginx.org packages) or sites-available plus a link in sites-enabled (Debian, Ubuntu). If the Config Generator's output starts with the WebSocket map, the same mistake says "map" directive is not allowed here.

Full guide: five causes, the exact messages, and brace mistakes →

Why does my Let's Encrypt renewal fail behind an HTTPS redirect?

With certbot --webroot, Let's Encrypt checks a file at http://your-domain/.well-known/acme-challenge/. If port 80 redirects everything to HTTPS, that check is redirected too, often into your app, and renewal fails weeks after setup, when Certbot first tries to renew, with no warning. The port 80 block needs an exception:

location /.well-known/acme-challenge/ {
    root /var/www/html;
}
location / {
    return 301 https://$host$request_uri;
}

The return must sit inside location /: a return placed directly in the server block runs before Nginx looks at any location. ProxyForge's HTTPS and redirect output already includes this. Test it now with sudo certbot renew --dry-run.

Full guide: the exact Certbot error, Nginx and Apache fixes, and how to check before the next renewal →

Why can't my .htaccess use ProxyPass?

Apache only allows ProxyPass, ProxyPassReverse and ProxyPreserveHost in the main server config or a virtual host, never in .htaccess, even with AllowOverride All. In .htaccess the only way to proxy is mod_rewrite's [P] flag, which needs mod_proxy, mod_proxy_http and mod_rewrite enabled. That's what the Config Generator outputs in Apache mode. If you need the original Host header passed through or backend redirects rewritten, move the proxy rules into the virtual host. Full guide with tested templates →

Why does Apache say Invalid command 'ProxyPass'?

Apache doesn't recognise the line because the module that defines it isn't loaded. ProxyPass, ProxyPassReverse and ProxyPreserveHost need mod_proxy, and proxying to an http:// app also needs mod_proxy_http; RequestHeader needs mod_headers. On Debian and Ubuntu run sudo a2enmod proxy proxy_http headers (or the full a2enmod line in the Config Generator's output), then sudo apache2ctl configtest, then restart Apache. On RHEL, AlmaLinux and Rocky these modules are on by default. The error names the first line Apache doesn't know, so it often says ProxyPreserveHost or RequestHeader instead of ProxyPass.

Full guide: which line needs which module, and why Syntax OK can still mean a 500 →

Why do uploads fail with 413 Request Entity Too Large?

Nginx rejects request bodies over 1 MB by default. Raise the limit with client_max_body_size, for example client_max_body_size 50m;, using the Max upload size field in the Config Generator, then test and reload. On Apache, see Upload fails on Apache: which limit is it?

Full guide: every upload limit, how to tell which one refused it, and the tested fix →

Why won't Apache start after I added SSLStaplingCache?

SSLStaplingCache (like SSLSessionCache) is only allowed in the main server config, outside any <VirtualHost>. Put it inside a virtual host and apachectl configtest fails with "SSLStaplingCache cannot occur within <VirtualHost> section". Leave it out completely while SSLUseStapling on is set and Apache won't start, even though configtest says "Syntax OK". With a Let's Encrypt certificate you don't need either line: Let's Encrypt removed OCSP from its certificates in 2025, so delete SSLUseStapling and SSLStaplingCache.

Full guide: the exact errors, why stapling does nothing with Let's Encrypt now, and what to remove →

Why does my Apache redirect loop with too many redirects?

Usually the rule matches the URL it redirects to. Redirect 301 / http://example.com/ inside example.com's own virtual host matches every path, including the target, and an HTTPS rule like RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] without RewriteCond %{HTTPS} off keeps redirecting HTTPS to itself. Add the condition (the Redirect Generator's HTTPS output has it) or narrow the path. If it only loops behind Cloudflare, see the Cloudflare answer.

Full guide: Redirect vs RewriteRule, six traps and both loops, tested →

Why do I get ERR_TOO_MANY_REDIRECTS behind Cloudflare?

Cloudflare's Flexible SSL mode connects to your server over plain HTTP, so your HTTP-to-HTTPS redirect sends every request back to HTTPS forever. Set Cloudflare's SSL/TLS mode to Full (strict), which needs a valid certificate on your server. Tick Behind Cloudflare in the Config Generator to also restore real visitor IPs.

Full guide: why Flexible loops, the tested fix, and why Chrome keeps showing the error afterwards →

nginx -t passes, but nothing answers on port 443. Why?

Usually the site file is empty or not enabled. A paste into nano can silently fail and save an empty file, which still passes the test. Check that the file has content with grep -c . /etc/nginx/sites-available/your-site, that it's linked into /etc/nginx/sites-enabled/, and that Nginx is listening with sudo ss -tlnp | grep :443. Then run sudo nginx -t && sudo systemctl reload nginx again.

Why do I get 502 Bad Gateway from Nginx or Apache?

The proxy is working, but it can't reach your app. Check the error log for the exact reason: sudo tail -n 20 /var/log/nginx/error.log (or /var/log/apache2/error.log, /var/log/httpd/error_log on RHEL).

  • connect() failed (111: Connection refused) while connecting to upstream (Apache: AH00957 ... failed): nothing is listening on the backend address. Check the app is running (systemctl status your-app or docker ps) and listening on the port you set: sudo ss -tlnp | grep :3000. A typo in the port is common.
  • connect() to 127.0.0.1:3000 failed (13: Permission denied): on RHEL, Rocky or Alma, SELinux blocks the web server from making network connections. Allow it with sudo setsebool -P httpd_can_network_connect 1.
  • The app is in Docker: publish its port to the host (-p 127.0.0.1:3000:3000), and make sure the app inside the container listens on 0.0.0.0, not only on localhost.

Once the app answers locally (curl -I http://127.0.0.1:3000), the 502 goes away. No reload needed. The backend address comes from the Config Generator's Backend field.

Full guide: every 502 log line, its cause and the tested fix →

Why does Apache give 403 Forbidden with AH01630: client denied by server configuration?

An Apache access rule refused the request. Usually the folder was never granted: Apache 2.4 starts from Require all denied and only opens folders you allow. Add <Directory /your/folder> with Require all granted for the DocumentRoot and every Alias target, then test and reload. On Debian and Ubuntu only /var/www and /usr/share are granted by default, so a site under /srv needs its own grant. Old Apache 2.2 lines (Order, Allow from all) on their own don't open the folder on 2.4; replace them with Require. The Config Generator's virtual host output includes the grant.

Full guide: the log line, the fix, and the 403s that aren't AH01630 →

Why does Nginx say bind() to 0.0.0.0:80 failed (98: Address already in use)?

Another program already owns port 80 (or 443), so Nginx can't start. Apache shows the same problem as (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80.

Don't stop processes blindly. First see what's actually listening: sudo ss -tlnp | grep -E ':(80|443) '. The usual answers:

  • Apache and Nginx both installed. Some packages pull in Apache, and it starts on port 80. Pick the one you want. If it's Nginx: sudo systemctl disable --now apache2 (httpd on RHEL).
  • An old Nginx process left over from a failed restart. sudo systemctl restart nginx usually clears it. Check with the ss command again.
  • Certbot in standalone mode needs port 80 free while it runs. Use the webroot or the Nginx/Apache plugin instead, as the SSL Generator offers.
  • Docker or another app publishing port 80. Move it to another port and proxy to it instead.

Then sudo nginx -t && sudo systemctl start nginx.

nginx -s reload said OK, but my change didn't apply. Why?

nginx -s reload catches syntax errors, but some problems only show up when Nginx applies the new config. Then the command still reports success, Nginx quietly keeps running the old config, and the reason goes to the error log. (With the nginx.org package, systemctl reload only sends a signal, so it reports success even for a syntax error.) One change that always does this: editing the key of an existing limit_req_zone (or limit_conn_zone). Tested on Nginx 1.27 and 1.30: nginx -t passes, the reload exits with 0, and the old key stays in use. The log shows:

[emerg] limit_req "one" uses the "$server_name" key while previously it used the "$binary_remote_addr" key

Two ways to apply it:

  • Restart instead of reload: sudo nginx -t && sudo systemctl restart nginx. Open connections are dropped for a moment.
  • Give the zone a new name (e.g. zone=one_v2) and update every limit_req zone= line that uses it. A normal reload then works.

Good habit after any reload: check it took with sudo tail -n 5 /var/log/nginx/error.log (or journalctl -u nginx -n 20).

Full guide: five tested causes and how to check a reload worked →

My app gets /apifoo instead of /api/foo. Why?

Your proxy_pass has a path that doesn't end in a slash, for example location / { proxy_pass http://127.0.0.1:3000/api; }. When proxy_pass includes a path, Nginx replaces the part of the request that matched the location (here /) with that path. So /foo loses its / and becomes /api + foo = /apifoo. nginx -t can't catch this, because the syntax is valid.

Fix: end the path with a slash, proxy_pass http://127.0.0.1:3000/api/;. Then /foo reaches your app as /api/foo, and query strings come through unchanged. Tested on Nginx 1.27 and 1.30 with a backend that echoes the path it receives. ProxyForge's Config Generator adds the slash for you and shows the mapping in a comment.

Check it took: curl -i https://yoursite.com/foo and look at the path in your app's access log.

Watch it in 23 seconds: the missing-slash Short on YouTube.

Full guide: what every location and proxy_pass combination sends, regex locations and Apache ProxyPass →

Upload fails on Apache: which limit is it?

Usually not Apache's. Several limits sit between the visitor and your app, and the first one that's too small wins. Check them in this order:

  • Cloudflare (if the site is proxied): the Free and Pro plans accept uploads up to 100 MB. Bigger ones get a 413 page branded by Cloudflare, before your server sees anything.
  • Nginx in front of Apache: client_max_body_size defaults to 1 MB, a 413 from Nginx. See the 413 answer.
  • Apache itself: LimitRequestBody defaults to 1 GB on Apache 2.4.54 and newer (it was unlimited before). Over that, requests Apache handles itself get a 413. At the default log level nothing about it is logged; with LogLevel info the error log says AH01588: Requested content-length of ... is larger than the configured limit of .... In our lab (Apache 2.4.68), LimitRequestBody didn't limit uploads to a reverse-proxied app wherever it was set, so check the app's own limit too.
  • PHP (WordPress and PHP apps): upload_max_filesize defaults to 2M and post_max_size to 8M. No 413 here: the upload just arrives empty, and WordPress says the file "exceeds the upload_max_filesize directive in php.ini". Raise both in php.ini (or your PHP-FPM pool config), keeping post_max_size larger, then restart PHP-FPM. Check the active values with php -i | grep -E "upload_max_filesize|post_max_size", or a phpinfo() page for PHP-FPM.
  • Your app (Node, Python, Go and so on): most frameworks have their own body-size limit, usually in the error the app logs or returns.

Tip: the response tells you who refused it. A 413 page that mentions Cloudflare, Nginx or Apache names the layer, and an error with no 413 usually comes from PHP or the app.

Full guide, including what Apache's LimitRequestBody does and doesn't cover →

About ProxyForge

Is ProxyForge free?

Yes. Every generator is free to use, with no signup and no paid tier. The site may show ads to cover its costs, and some links to hosting providers are affiliate links; the privacy page explains both.

Do I need to know Nginx or Apache syntax to use it?

Not to generate a config: you fill in a short form (domain, backend address, a few options) and copy the result. You do need enough to save the file in the right place, run the test command and read what it prints. Every config ends with the exact commands, such as sudo nginx -t && sudo systemctl reload nginx. Before you trust any generated config, from here or anywhere else, run the five checks in the generators comparison.

How is it different from writing the config by hand?

The output is the same plain config file you would write yourself, with nothing installed on your server. The difference is that the parts that are easy to get wrong are already done and tested on real servers: the trailing slash in proxy_pass, the Let's Encrypt renewal exception, the WebSocket headers and the right HTTP/2 line for your Nginx version (how it's tested). Writing by hand gives you full control, and ProxyForge has fewer options than a hand-written config or nginxconfig.io, so for unusual setups, start from the output and edit it.

Does anything I type leave my browser?

No. The configs are built by JavaScript in your browser, and domain names, addresses and the other fields are never sent to ProxyForge's server. When you click Copy, the page requests a small file so daily totals of copies per generator can be counted; that request contains nothing you typed. Details are on the privacy page.

Hit an error that isn't here?

Email admin@proxyforge.tech with the exact error message, your Nginx or Apache version and distro. Real errors get added to this page.

How to use ProxyForge · Guides · What's new · About · Featured On · Privacy