Customizing Network Settings for an Application

On Porter, you have the flexibility to customize the NGINX configuration for each of your Web service by adding an “Ingress Annotation” when deploying a web service. This can be found in the “Networking” tab of the web service:

Advanced tab ingress

To add an annotation, add the key-value pairs for an annotation you want to add. For a full list of NGINX annotations you can add to the service, please consult this documentation. Below are the most common custom networking options we see among our users.

Setting Custom Read/Write Timeouts

Read/write timeouts are very application-specific, and are subject to change on the Porter templates. For example, if you have a websocket application that does not handle dropped connections gracefully, you may be inclined to set your read/write timeout to be much higher than what is standard (~30 seconds). For those coming from Heroku, the Heroku router enforces a write timeout of 30 seconds, and will keep a connection alive if a single byte is sent within a 55 second window.

On Porter, you can configure your own read/write timeouts by adding annotations: "60" "60" "60"

Note: All timeout values are unitless and in seconds - for instance, "120" sets a valid 120 seconds proxy read timeout.

For an explanation of these values:

AnnotationDescription timeout for NGINX to establish a connection with your application. timeout for NGINX to transmit a request to your application. timeout for NGINX to read a response from your application.

It is thus recommended to set these values with the ordering proxy-connect-timeout <= proxy-send-timeout <= proxy-read-timeout.

Client Max Body Size

If you are getting undesired 413 Request Entity Too Large errors, you can increase the maximum size of the client request by setting the field client_max_body_size. You can do this by adding the following annotation: 8m

This will set the maximum client request body size to 8 megabytes.

To learn more about NGINX units, see this document.

Header Size

If you are occasionally getting 500-level errors on certain endpoints, your application may be sending response headers which are too large for NGINX to process. You can try increasing the maximum value of the response header size by setting something like the following (default is 1k): 10k