Buildpacks allow you to customize the web server for your application. Nginx and Apache2 are supported.
In case you want to adjust the default document root for your application (in your repository), you can set the path using the Runway CLI:
runway config set BP_WEBSERVER_ROOT=app/public
An alternative is to use a project.toml
:
[ build ]
[[ build.env ]]
name="BP_WEBSERVER_ROOT"
value="app/public"
Other variables are available in their designated buildpacks:
By including a configuration file in the root of your application repository, you can go all the way.
For nginx it’s an nginx.conf
and for Apache2 it’s a httpd.conf
. Make sure either configuration file configures the entire server (not a single virtual host).
For example, to configure nginx to use the user’s actual IP address, the following snippet will give you an idea for what is expected:
worker_processes 1;
daemon off;
error_log stderr;
events {
worker_connections 1024;
}
http {
charset utf-8;
access_log /dev/stdout;
default_type application/octet-stream;
include mime.types;
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
# Ensure that redirects don't include the internal container PORT - 8080
port_in_redirect off;
set_real_ip_from 10.244.0.0/16;
real_ip_header X-Forwarded-For;
server {
port_in_redirect off;
absolute_redirect off;
listen {{port}};
# snip
}
}
Along with the nginx.conf
, you will also need to add a mime.types
file and the complete server
block; for a complete example the how to deploy an Angular app).
Otherwise, anything that nginx supports will work on Runway.
listen {{port}};
directive, to avoid hard-coding this setting. This allows runway app config set PORT=1234
to work, so you don’t need to update the setting in the configuration file.port_in_redirect off;
and absolute_redirect off;
if you supply a custom configuration file. The buildpack will take care of this for you.