NGINX Proxy Manager MCP Server

I updated an existing project of mine and added MCP to it. This project https://dep.leighonline.net/ui is already up and running with a neat swagger endpoint https://dep.leighonline.net/swagger as well.

I added a new endpoint https://dep.leighonline.net/mcp and had to expose it via NGINX Proxy Manager.

The easiest way to do this was to add a custom location to the existing Proxy Host in NGINX.


NGINX Proxy Manager Custom Location for MCP

nginx proxy manager proxy host custom location mcp
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_buffering off;
proxy_cache off;
chunked_transfer_encoding off;
proxy_read_timeout 24h;


What this custom NGINX config does and why you need it for MCP

  • proxy_http_version 1.1; Forces NGINX to use HTTP/1.1 to communicate with your backend. This is strictly required because the older HTTP/1.0 protocol automatically closes connections after a single request, which would instantly kill your ongoing SSE stream (Server-Sent Events).
  • proxy_set_header Connection ''; By default, NGINX might tell the backend to close the connection once it thinks the job is done. Setting this header to an empty string overrides that behavior and ensures the connection stays open for the persistent data stream.
  • proxy_buffering off; This is the most critical setting. Normally, NGINX waits to collect a large chunk of data in a buffer before sending it to the user to save network overhead. Turning this off forces NGINX to pass every piece of data to the client the exact millisecond it arrives, ensuring true real-time streaming.
  • proxy_cache off; Prevents NGINX from attempting to save or cache the responses. Real-time streams are entirely dynamic, so caching them would only cause stale data and unexpected behavior.
  • chunked_transfer_encoding off; Server-Sent Events handle their own specific formatting for sending data frames. Turning this off stops NGINX from trying to apply its own chunking logic on top of the stream, preventing data corruption.
  • proxy_read_timeout 24h; The default NGINX read timeout is usually around 60 seconds. If your AI model takes longer than a minute to process a response or if the connection sits idle, NGINX would normally drop the connection. Bumping this to 24 hours ensures your streams stay alive pretty much indefinitely.

necrolingus

Tech enthusiast and home labber