You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/asciidoc/servers.adoc
+182Lines changed: 182 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,8 @@ Server options are available via javadoc:ServerOptions[] class:
45
45
.setSingleLoop(false)
46
46
.setDefaultHeaders(true)
47
47
.setMaxRequestSize(10485760)
48
+
.setSecurePort(8433)
49
+
.setSsl(SslOptions.selfSigned())
48
50
);
49
51
}
50
52
----
@@ -62,6 +64,8 @@ Server options are available via javadoc:ServerOptions[] class:
62
64
singleLoop = false
63
65
defaultHeaders = true
64
66
maxRequestSize = 10485760
67
+
securePort = 8443
68
+
ssl = SslOptions.selfSigned()
65
69
}
66
70
}
67
71
----
@@ -74,6 +78,8 @@ Server options are available via javadoc:ServerOptions[] class:
74
78
- singleLoop: Indicates if the web server should use a single loop/group for doing IO or not. **Netty only**.
75
79
- defaultHeaders: Configure server to set the following headers: `Date`, `Content-Type` and `Server` headers.
76
80
- maxRequestSize: Maximum request size in bytes. Request exceeding this value results in 413(REQUEST_ENTITY_TOO_LARGE) response. Default is `10mb`.
81
+
- securePort: Configure Jooby to do HTTPs. This option is fully convered in next section.
82
+
- ssl: SSL options with certificate details. This option is fully convered in next section.
77
83
78
84
Server options are available as application configuration properties too:
79
85
@@ -88,4 +94,180 @@ server.gzip = false
88
94
server.singleLoop = false
89
95
server.defaultHeaders = true
90
96
server.maxRequestSize = 10485760
97
+
server.securePort = 8443
98
+
server.ssl.type = self-signed
99
+
----
100
+
101
+
=== SSL
102
+
103
+
Jooby supports HTTPS out of the box. By default HTTPS is disabled and all requests are served using
104
+
HTTP. To enable HTTPS support, modify your configuration.
105
+
106
+
.SSL Options
107
+
[source,java,role="primary"]
108
+
----
109
+
{
110
+
setServerOptions(new ServerOptions()
111
+
.setSecurePort(8443) <1>
112
+
);
113
+
}
114
+
----
115
+
116
+
.Kotlin
117
+
[source,kotlin,role="secondary"]
118
+
----
119
+
{
120
+
serverOptions {
121
+
securePort = 8443 <1>
122
+
}
123
+
}
124
+
----
125
+
126
+
<1> Set secure port and use a self-signed certificate
127
+
128
+
Once SSL is enabled application logs print something like:
129
+
130
+
----
131
+
listening on:
132
+
http://localhost:8080/
133
+
https://localhost:8443/
134
+
----
135
+
136
+
The `self-signed` certificate is useful for development and only works for `localhost`.
137
+
138
+
Jooby supports two certificate formats:
139
+
140
+
- PKCS12 (this is the default format)
141
+
- X.509
142
+
143
+
The javadoc:SslOptions[] class provides options to configure SSL:
144
+
145
+
- cert: A PKCS12 or X.509 certificate chain file in PEM format. It can be an absolute path or a classpath resource. Required.
146
+
- key: A PKCS#8 private key file in PEM format. It can be an absolute path or a classpath resource. Required when using X.509 certificates.
147
+
- password: Password to use (if any). Optional. Default is: null/empty.
148
+
149
+
==== Using X.509
150
+
151
+
It is also possible to configure Jooby to use a X.509 certificate, for example one created with https://letsencrypt.org/[Let’s Encrypt]. You will need the `*.crt` and `*.key` files:
0 commit comments