Skip to content

Commit d9e5435

Browse files
ayushn21ioquatix
authored andcommitted
Improve deployment docs to mention use of self-signed certs
1 parent d57b18c commit d9e5435

2 files changed

Lines changed: 102 additions & 10 deletions

File tree

context/deployment.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,22 @@ service "supervisor" do
5656
end
5757
~~~
5858

59-
These configuration blocks are evaluated using the [async-service](https://github.com/socketry/async-service) gem. The supervisor is an independent service which monitors the health of the application and can restart it if necessary. Other services like background job processors can be added to the configuration.
59+
These configuration blocks are evaluated using the [async-service](https://github.com/socketry/async-service) gem. This configuration will bind Falcon to an [IPC socket](https://en.wikipedia.org/wiki/Unix_domain_socket) and is designed to be used with a reverse proxy such as [`falcon virtual`](#falcon-virtual).
60+
61+
The supervisor is an independent service which monitors the health of the application and can restart it if necessary. Other services like background job processors can be added to the configuration.
6062

6163
### Environments
6264

6365
The service blocks define configuration that is loaded by the service layer to control how the service is run. The `service ... do` block defines the service name and the environment in which it runs. Different modules can be included to provide different functionality, such as `Falcon::Environment::Rack` for Rack applications, or `Falcon::Environment::LetsEncryptTLS` for automatic TLS certificate management.
6466

67+
**NOTE**: Falcon does not provision or renew certificates automatically. Use a tool like [certbot](https://certbot.eff.org) to provision your certificate and the `LetsEncryptTLS` environment will automatically read it in.
68+
6569
### Application Configuration
6670

6771
The environment configuration is defined in the `Falcon::Environment` module. The {ruby Falcon::Environment::Application} environment supports the generic virtual host functionality, but you can customise any parts of the configuration, e.g. to bind a production host to `localhost:3000` using plaintext HTTP/2:
6872

6973
~~~ ruby
70-
#!/usr/bin/env falcon host
74+
#!/usr/bin/env falcon-host
7175
# frozen_string_literal: true
7276

7377
require "falcon/environment/rack"
@@ -76,12 +80,54 @@ require "async/service/supervisor"
7680
hostname = File.basename(__dir__)
7781
service hostname do
7882
include Falcon::Environment::Rack
79-
include Falcon::Environment::LetsEncryptTLS
8083

8184
endpoint do
8285
Async::HTTP::Endpoint
8386
.parse('http://localhost:3000')
84-
.with(protocol: Async::HTTP::Protocol::HTTP2)
87+
.with(
88+
protocol: Async::HTTP::Protocol::HTTP2
89+
)
90+
end
91+
end
92+
93+
service "supervisor" do
94+
include Async::Service::Supervisor::Environment
95+
end
96+
~~~
97+
98+
You can verify this is working using the [`nghttp2` client](https://nghttp2.org): `nghttp -v http://localhost:3000`. This will not work in a browser as they mandate TLS for HTTP/2 connections.
99+
100+
#### Self-signed certificate
101+
102+
You can use a self-signed certificate to test your server configuration locally. First, provision a certificate using the [`localhost` gem](https://github.com/socketry/localhost):
103+
104+
```
105+
$ bundle exec bake localhost:install
106+
```
107+
108+
You may be prompted for a password to install the certificate. This is the password for your local keychain.
109+
110+
Then, add the `SelfSignedTLS` environment to your configuration and set up the SSL context:
111+
112+
~~~ ruby
113+
#!/usr/bin/env falcon-host
114+
# frozen_string_literal: true
115+
116+
require "falcon/environment/rack"
117+
require "async/service/supervisor"
118+
119+
hostname = File.basename(__dir__)
120+
service hostname do
121+
include Falcon::Environment::Rack
122+
include Falcon::Environment::SelfSignedTLS
123+
124+
endpoint do
125+
Async::HTTP::Endpoint
126+
.parse('https://localhost:3000')
127+
.with(
128+
protocol: Async::HTTP::Protocol::HTTP2,
129+
ssl_context: ssl_context
130+
)
85131
end
86132
end
87133

@@ -90,7 +136,7 @@ service "supervisor" do
90136
end
91137
~~~
92138

93-
You can verify this is working using `nghttp -v http://localhost:3000`.
139+
You should now be able to access your server at `https://localhost:3000` in your browser.
94140

95141
#### Application Configuration Example for Heroku
96142

guides/deployment/readme.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,22 @@ service "supervisor" do
5656
end
5757
~~~
5858

59-
These configuration blocks are evaluated using the [async-service](https://github.com/socketry/async-service) gem. The supervisor is an independent service which monitors the health of the application and can restart it if necessary. Other services like background job processors can be added to the configuration.
59+
These configuration blocks are evaluated using the [async-service](https://github.com/socketry/async-service) gem. This configuration will bind Falcon to an [IPC socket](https://en.wikipedia.org/wiki/Unix_domain_socket) and is designed to be used with a reverse proxy such as [`falcon virtual`](#falcon-virtual).
60+
61+
The supervisor is an independent service which monitors the health of the application and can restart it if necessary. Other services like background job processors can be added to the configuration.
6062

6163
### Environments
6264

6365
The service blocks define configuration that is loaded by the service layer to control how the service is run. The `service ... do` block defines the service name and the environment in which it runs. Different modules can be included to provide different functionality, such as `Falcon::Environment::Rack` for Rack applications, or `Falcon::Environment::LetsEncryptTLS` for automatic TLS certificate management.
6466

67+
**NOTE**: Falcon does not provision or renew certificates automatically. Use a tool like [certbot](https://certbot.eff.org) to provision your certificate and the `LetsEncryptTLS` environment will automatically read it in.
68+
6569
### Application Configuration
6670

6771
The environment configuration is defined in the `Falcon::Environment` module. The {ruby Falcon::Environment::Application} environment supports the generic virtual host functionality, but you can customise any parts of the configuration, e.g. to bind a production host to `localhost:3000` using plaintext HTTP/2:
6872

6973
~~~ ruby
70-
#!/usr/bin/env falcon host
74+
#!/usr/bin/env falcon-host
7175
# frozen_string_literal: true
7276

7377
require "falcon/environment/rack"
@@ -76,12 +80,54 @@ require "async/service/supervisor"
7680
hostname = File.basename(__dir__)
7781
service hostname do
7882
include Falcon::Environment::Rack
79-
include Falcon::Environment::LetsEncryptTLS
8083

8184
endpoint do
8285
Async::HTTP::Endpoint
8386
.parse('http://localhost:3000')
84-
.with(protocol: Async::HTTP::Protocol::HTTP2)
87+
.with(
88+
protocol: Async::HTTP::Protocol::HTTP2
89+
)
90+
end
91+
end
92+
93+
service "supervisor" do
94+
include Async::Service::Supervisor::Environment
95+
end
96+
~~~
97+
98+
You can verify this is working using the [`nghttp2` client](https://nghttp2.org): `nghttp -v http://localhost:3000`. This will not work in a browser as they mandate TLS for HTTP/2 connections.
99+
100+
#### Self-signed certificate
101+
102+
You can use a self-signed certificate to test your server configuration locally. First, provision a certificate using the [`localhost` gem](https://github.com/socketry/localhost):
103+
104+
```
105+
$ bundle exec bake localhost:install
106+
```
107+
108+
You may be prompted for a password to install the certificate. This is the password for your local keychain.
109+
110+
Then, add the `SelfSignedTLS` environment to your configuration and set up the SSL context:
111+
112+
~~~ ruby
113+
#!/usr/bin/env falcon-host
114+
# frozen_string_literal: true
115+
116+
require "falcon/environment/rack"
117+
require "async/service/supervisor"
118+
119+
hostname = File.basename(__dir__)
120+
service hostname do
121+
include Falcon::Environment::Rack
122+
include Falcon::Environment::SelfSignedTLS
123+
124+
endpoint do
125+
Async::HTTP::Endpoint
126+
.parse('https://localhost:3000')
127+
.with(
128+
protocol: Async::HTTP::Protocol::HTTP2,
129+
ssl_context: ssl_context
130+
)
85131
end
86132
end
87133

@@ -90,7 +136,7 @@ service "supervisor" do
90136
end
91137
~~~
92138

93-
You can verify this is working using `nghttp -v http://localhost:3000`.
139+
You should now be able to access your server at `https://localhost:3000` in your browser.
94140

95141
#### Application Configuration Example for Heroku
96142

0 commit comments

Comments
 (0)