Merge pull request #707 from WalkerWatch/jetty-9.3.x
Chapter 6 fixes, removal of Quickstart pieces for #679.
This commit is contained in:
commit
7f5213e668
|
@ -28,8 +28,8 @@ Jetty primarily uses a single connector type called link:{JDURL}/org/eclipse/jet
|
|||
|
||||
____
|
||||
[NOTE]
|
||||
Prior to Jetty 9, the type of the connector specified both the protocol and the implementation used (for example, selector-based non blocking I/O vs blocking I/O, or SSL connector vs non-SSL connector).
|
||||
Jetty 9 has only a selector-based non blocking I/O connector, and a collection of link:{JDURL}/org/eclipse/jetty/server/ConnectionFactory.html[`ConnectionFactories`] now configure the protocol on the connector.
|
||||
Prior to Jetty 9, the type of the connector specified both the protocol and the implementation used; for example, selector-based non blocking I/O vs blocking I/O, or SSL connector vs non-SSL connector.
|
||||
Jetty 9 has a single selector-based non-blocking I/O connector, and a collection of link:{JDURL}/org/eclipse/jetty/server/ConnectionFactory.html[`ConnectionFactories`] now configure the protocol on the connector.
|
||||
____
|
||||
|
||||
The standard Jetty distribution comes with the following Jetty XML files that create and configure connectors; you should examine them as you read this section:
|
||||
|
@ -46,13 +46,13 @@ link:{SRCDIR}/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml[`jett
|
|||
link:{SRCDIR}/jetty-alpn/jetty-alpn-server/src/main/config/etc/jetty-alpn.xml[`jetty-alpn.xml`]::
|
||||
Adds an link:{JDURL}/org/eclipse/jetty/alpn/server/ALPNServerConnectionFactory.html[`ALPNServerConnectionFactory`] to the link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] configured by `jetty-ssl.xml` which allows the one SSL connector to support multiple protocols with the ALPN extension used to select the protocol to be used for each connection.
|
||||
|
||||
Typically you need to configure very little on connectors other than set the listening port (see link:#jetty-connectors-network-settings[Network Settings]), and perhaps enable `X-Forwarded-For` customization (see link:#jetty-connectors-http-configuration[HTTP Configuration]).
|
||||
Most other settings are for expert configuration only.
|
||||
Typically connectors require very little configuration aside from setting the listening port (see link:#jetty-connectors-network-settings[Network Settings]), and enabling `X-Forwarded-For` customization when applicable. (see link:#jetty-connectors-http-configuration[HTTP Configuration]).
|
||||
Additional settings are for expert configuration only.
|
||||
|
||||
==== Constructing a `ServerConnector`
|
||||
==== Constructing a ServerConnector
|
||||
|
||||
The services a link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] instance uses are set by constructor injection and once instantiated cannot be changed.
|
||||
Most of the services may be defaulted with null or 0 values so that a reasonable default is used, thus for most purposes only the Server and the connection factories need to be passed to the connector constructor. In Jetty XML (that is, in link:{SRCDIR}/jetty-server/src/main/config/etc/jetty-http.xml[`jetty-http.xml`]), you can do this by:
|
||||
Many of the services may be defaulted with null or 0 values so that a reasonable default is used, thus for most purposes only the Server and the connection factories need to be passed to the connector constructor. In Jetty XML (that is, in link:{SRCDIR}/jetty-server/src/main/config/etc/jetty-http.xml[`jetty-http.xml`]) you can do this by:
|
||||
|
||||
[source, xml, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -202,9 +202,9 @@ Jetty supports the `X-Forwarded-For` header and the http://www.haproxy.org/downl
|
|||
|
||||
____
|
||||
[NOTE]
|
||||
The XML files in the jetty distribution contain commented out examples of both the `X-Forwarded-For` and http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt[Proxy Protocol] mechanisms.
|
||||
When using those examples, it is recommended that the XML in the jetty distribution is not edited.
|
||||
Rather the files should be copied into a jetty base directory and then modified.
|
||||
The XML files in the Jetty distribution contain commented out examples of both the `X-Forwarded-For` and http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt[Proxy Protocol] mechanisms.
|
||||
When using those examples, it is recommended that the XML in the Jetty distribution is not edited.
|
||||
Rather the files should be copied into a Jetty base directory and then modified.
|
||||
____
|
||||
|
||||
===== X-Forward-for Configuration
|
||||
|
|
|
@ -26,9 +26,9 @@ Which browser/OS supports which protocols can be https://en.wikipedia.org/wiki/T
|
|||
|
||||
* TLS v1.1 and v1.2: The protocols which should be used wherever possible.
|
||||
All CBC based ciphers are supported since Java 7, the new GCM modes are supported since Java 8.
|
||||
* TLS v1.0: still supported but is affected by the POODLE attack.
|
||||
* TLS v1.0: Still supported but is affected by the link:https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2014-3566[POODLE attack.]
|
||||
To support older browsers this protocol version is still needed.
|
||||
* SSL v3: is now deprecated and should only be enabled if you still need to support very old browsers like Internet Explorer 6 on Windows XP which does not support TLS 1.0 (or is disabled by default).
|
||||
* SSL v3: is now deprecated and should *only* be enabled if you still need to support very old browsers like Internet Explorer 6 on Windows XP which does not support TLS 1.0 (or is disabled by default).
|
||||
|
||||
[[understanding-certificates-and-keys]]
|
||||
==== Understanding Certificates and Keys
|
||||
|
@ -55,9 +55,7 @@ For testing, the `keytool` utility bundled with the JDK provides the simplest wa
|
|||
You can also use the OpenSSL tools to generate keys and certificates, or to convert those that you have used with Apache or other servers.
|
||||
Since Apache and other servers commonly use the OpenSSL tool suite to generate and manipulate keys and certificates, you might already have some keys and certificates created by OpenSSL, or you might also prefer the formats OpenSSL produces.
|
||||
|
||||
If you want the option of using the same certificate with Jetty or a web
|
||||
server such as Apache not written in Java, you might prefer to generate
|
||||
your private key and certificate with OpenSSL.
|
||||
If you want the option of using the same certificate with Jetty or a web server such as Apache not written in Java, you might prefer to generate your private key and certificate with OpenSSL.
|
||||
|
||||
[[configuring-jetty-for-ssl]]
|
||||
===== Configuring Jetty for SSL
|
||||
|
@ -132,8 +130,8 @@ $ keytool -keystore keystore -alias jetty -genkey -keyalg RSA -sigalg SHA256with
|
|||
----
|
||||
|
||||
You now have the minimal requirements to run an SSL connection and could proceed directly to link:#configuring-sslcontextfactory[configure an SSL connector].
|
||||
However, the browser will not trust the certificate you have generated, and prompts the user to this effect.
|
||||
While what you have at this point is often sufficient for testing, most public sites need a trusted certificate, as shown in the section link:#generating-csr-from-keytool[generating a CSR with keytool].
|
||||
However, the browser _will not_ trust the certificate you have generated, and prompts the user to this effect.
|
||||
While what you have at this point is often sufficient for testing, most public sites need a trusted certificate, which is demonstrated in the section link:#generating-csr-from-keytool[generating a CSR with keytool].
|
||||
|
||||
If you want to use only a self signed certificate for some kind of internal admin panel add -validity <days> to the keytool call above, otherwise your certificate is only valid for one month.
|
||||
|
||||
|
@ -200,8 +198,8 @@ $
|
|||
----
|
||||
|
||||
You now have the minimal requirements to run an SSL connection and could proceed directly to xref:loading-keys-and-certificates[] to load these keys and certificates into a JSSE keystore.
|
||||
However the browser will not trust the certificate you have generated, and prompts the user to this effect.
|
||||
While what you have at this point is often sufficient for testing, most public sites need a trusted certificate, as shown in the section, xref:generating-csr-from-openssl[] to obtain a certificate.
|
||||
However the browser _will not_ trust the certificate you have generated, and prompts the user to this effect.
|
||||
While what you have at this point is often sufficient for testing, most public sites need a trusted certificate, which is demonstrated in the section, xref:generating-csr-from-openssl[] to obtain a certificate.
|
||||
|
||||
[[using-keys-and-certificates-from-other-sources]]
|
||||
====== Using Keys and Certificates from Other Sources
|
||||
|
@ -260,7 +258,8 @@ You can use `keytool` to load a certificate in PEM form directly into a keystore
|
|||
The PEM format is a text encoding of certificates; it is produced by OpenSSL, and is returned by some CAs.
|
||||
An example PEM file is:
|
||||
|
||||
....
|
||||
[source, screen, subs="{sub-order}"]
|
||||
----
|
||||
jetty.crt
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICSDCCAfKgAwIBAgIBADANBgkqhkiG9w0BAQQFADBUMSYwJAYDVQQKEx1Nb3J0
|
||||
|
@ -277,7 +276,7 @@ cnRiYXkub3JnggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADQQA6NkaV
|
|||
OtXzP4ayzBcgK/qSCmF44jdcARmrXhiXUcXzjxsLjSJeYPJojhUdC2LQKy+p4ki8
|
||||
Rcz6oCRvCGCe5kDB
|
||||
-----END CERTIFICATE-----
|
||||
....
|
||||
----
|
||||
|
||||
The following command loads a PEM encoded certificate in the `jetty.crt` file into a JSSE keystore:
|
||||
|
||||
|
@ -314,11 +313,14 @@ $ cat example.crt intermediate.crt [intermediate2.crt] ... rootCA.crt > cert-cha
|
|||
$ openssl pkcs12 -export -inkey example.key -in cert-chain.txt -out example.pkcs12
|
||||
----
|
||||
|
||||
The order of certificates must be from server to rootCA, as per RFC2246 section 7.4.2.
|
||||
____
|
||||
[NOTE]
|
||||
The order of certificates must be from server to rootCA, as per link:https://www.ietf.org/rfc/rfc2246.txt[RFC2246 section 7.4.2.]
|
||||
____
|
||||
|
||||
OpenSSL asks for an __export password__.
|
||||
A non-empty password is required to make the next step work.
|
||||
Then load the resulting PKCS12 file into a JSSE keystore with `keytool`:
|
||||
Load the resulting PKCS12 file into a JSSE keystore with `keytool`:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -332,7 +334,7 @@ If you are updating your configuration to use a newer certificate, as when the o
|
|||
If you imported the key and certificate originally using the PKCS12 method, use an alias of "1" rather than "jetty", because that is the alias the PKCS12 process enters into the keystore.
|
||||
|
||||
[[configuring-sslcontextfactory]]
|
||||
==== Configuring the Jetty `SslContextFactory`
|
||||
==== Configuring the Jetty SslContextFactory
|
||||
|
||||
The generated SSL certificates from above are held in the key store are configured in an instance of link:{JDURL}/org/eclipse/jetty/util/ssl/SslContextFactory.html[SslContextFactory] object.
|
||||
|
||||
|
@ -349,25 +351,25 @@ The `SslContextFactory` is responsible for:
|
|||
* https://en.wikipedia.org/wiki/Online_Certificate_Status_Protocol[OCSP] Support
|
||||
* Client Authentication Support
|
||||
|
||||
For Jetty Connectors, the configured `SslContextFactory` is injected into a specific `ServerConnector` `SslConnectionFactory`.
|
||||
For Jetty Connectors, the configured `SslContextFactory` is injected into a specific ServerConnector `SslConnectionFactory`.
|
||||
|
||||
For Jetty Clients, the various constructors support using a configured `SslContextFactory`.
|
||||
|
||||
While the `SslContextFactory` can operate without a keystore (this mode is most suitable for the various Jetty Clients) it is best if you at least configure the keystore you are using.
|
||||
While the `SslContextFactory` can operate without a keystore (this mode is most suitable for the various Jetty Clients) it is best practice to at least configure the keystore being used.
|
||||
|
||||
setKeyStorePath::
|
||||
The configured keystore to use for all SSL/TLS in configured Jetty Connector (or Client).
|
||||
____
|
||||
[NOTE]
|
||||
As a keystore is vital security information, it can be desirable to locate the file in a directory with very restricted access.
|
||||
As a keystore is vital security information, it can be desirable to locate the file in a directory with *very* restricted access.
|
||||
____
|
||||
|
||||
setKeyStorePassword::
|
||||
The keystore password may be set here in plain text, or as some protection from casual observation, it may be obfuscated using the link:{JDURL}/org/eclipse/jetty/util/security/Password.html[Password] class.
|
||||
The keystore password may be set here in plain text, or as some measure of protection from casual observation, it may be obfuscated using the link:{JDURL}/org/eclipse/jetty/util/security/Password.html[Password] class.
|
||||
setTrustStorePath::
|
||||
This is used if validating client certificates and is typically set to the same path as the keystore.
|
||||
setKeyManagerPassword::
|
||||
Password that is passed to the `KeyManagerFactory.init(...)`.
|
||||
The password that is passed to the `KeyManagerFactory.init(...)`.
|
||||
If there is no `keymanagerpassword`, then the `keystorepassword` is used instead.
|
||||
If there is no `trustmanager` set, then the keystore is used as the trust store and the `keystorepassword` is used as the truststore password.
|
||||
setExcludeCipherSuites / setIncludeCipherSuites::
|
||||
|
@ -432,19 +434,19 @@ When using the `ExtendedSSlContextFactory`, the correct certificate is automatic
|
|||
[[configuring-sslcontextfactory-cipherSuites]]
|
||||
==== Disabling/Enabling Specific Cipher Suites
|
||||
|
||||
For example to avoid the BEAST attack it is necessary to configure a specific set of cipher suites. This can either be done via link:{JDURL}/org/eclipse/jetty/util/ssl/SslContextFactory.html#setIncludeCipherSuites(java.lang.String...)[SslContext.setIncludeCipherSuites(java.lang.String...)] or vialink:{JDURL}/org/eclipse/jetty/util/ssl/SslContextFactory.html#setExcludeCipherSuites(java.lang.String...)[SslContext.setExcludeCipherSuites(java.lang.String...)].
|
||||
As an example, to avoid the BEAST attack it is necessary to configure a specific set of cipher suites. This can either be done via link:{JDURL}/org/eclipse/jetty/util/ssl/SslContextFactory.html#setIncludeCipherSuites(java.lang.String...)[SslContext.setIncludeCipherSuites(java.lang.String...)] or vialink:{JDURL}/org/eclipse/jetty/util/ssl/SslContextFactory.html#setExcludeCipherSuites(java.lang.String...)[SslContext.setExcludeCipherSuites(java.lang.String...)].
|
||||
|
||||
____
|
||||
[NOTE]
|
||||
It's crucial that you use the exact names of the cipher suites as used/known by the JDK.
|
||||
It's crucial that you use the _exact_ names of the cipher suites as used/known by the JDK.
|
||||
You can get them by obtaining an instance of SSLEngine and call `getSupportedCipherSuites()`.
|
||||
Tools like ssllabs.com might report slightly different names which will be ignored.
|
||||
____
|
||||
|
||||
____
|
||||
[NOTE]
|
||||
It's recommended to install the Java Cryptography Extension (JCE) Unlimited Strength policy files in your JRE to get full strength ciphers like AES-256.
|
||||
They can be found on the http://www.oracle.com/technetwork/java/javase/downloads/index.html[Java download page].
|
||||
It's recommended to install the Java Cryptography Extension (JCE) Unlimited Strength policy files in your JRE to get full strength ciphers such as AES-256.
|
||||
The files can be found on the http://www.oracle.com/technetwork/java/javase/downloads/index.html[Java download page].
|
||||
Just overwrite the two present JAR files in `<JRE_HOME>/lib/security/`.
|
||||
____
|
||||
|
||||
|
@ -452,7 +454,7 @@ Both `setIncludeCipherSuites` and `setExcludeCipherSuites` can be fed by the exa
|
|||
|
||||
If you have a need to adjust the Includes or Excludes, then this is best done with a custom blow-in XML that configures the `SslContextFactory` to suit your needs.
|
||||
|
||||
To do this, first create a new `${jetty.base}/etc/tweak-ssl.xml` (thiscan be any name, just avoid prefixing it with "jetty-").
|
||||
To do this, first create a new `${jetty.base}/etc/tweak-ssl.xml` file (this can be any name, just avoid prefixing it with "jetty-").
|
||||
|
||||
[source, xml, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -473,10 +475,10 @@ To do this, first create a new `${jetty.base}/etc/tweak-ssl.xml` (thiscan be any
|
|||
</Configure>
|
||||
----
|
||||
|
||||
This new XML will configure the id `sslContextFactory` some more (this id is first created by the `ssl` module and its associated `${jetty.home}/etc/jetty-ssl-context.xml`).
|
||||
This new XML will configure the id `sslContextFactory` further (this id is first created by the `ssl` module and its associated `${jetty.home}/etc/jetty-ssl-context.xml`).
|
||||
You can do anything you want with the `SslContextFactory` in use by the Jetty Distribution from this tweaked XML.
|
||||
|
||||
To make sure that your `${jetty.base}` uses this new XML, add it to the end of your `${jetty.base}/start.ini`
|
||||
To make sure that your `${jetty.base}` uses this new XML, add it to the end of your `${jetty.base}/start.ini` or `${jetty.base}/start.d/server.ini`.
|
||||
|
||||
[source, plain, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -494,8 +496,8 @@ $
|
|||
____
|
||||
[NOTE]
|
||||
The default `SslContextFactory` implementation applies the latest SSL/TLS recommendations surrounding vulnerabilities in SSL/TLS.
|
||||
Check the release notes (The `VERSION.txt` found in the root of the Jetty Distribution, or the http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.eclipse.jetty%22%20AND%20a%3A%22jetty-project%22[alternate (classified 'version') artifacts for the `jetty-project` component]on Maven Central) for updates.
|
||||
The Java JVM is also applying exclusions at the JVM level, and as such, if you have a need to enable something that is generally accepted by the industry as being insecure or vulnerable you will likely have to enable it in BOTH the Java JVM and the Jetty configuration.
|
||||
Check the release notes (the `VERSION.txt` found in the root of the Jetty Distribution, or the http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.eclipse.jetty%22%20AND%20a%3A%22jetty-project%22[alternate (classified 'version') artifacts for the `jetty-project` component]on Maven Central) for updates.
|
||||
The Java JVM is also applying exclusions at the JVM level and as such if you have a need to enable something that is generally accepted by the industry as being insecure or vulnerable you will likely have to enable it in BOTH the Java JVM and the Jetty configuration.
|
||||
____
|
||||
|
||||
____
|
||||
|
@ -503,9 +505,9 @@ ____
|
|||
You can enable the `org.eclipse.jetty.util.ssl` named logger at DEBUG level to see what the list of selected Protocols and Cipher suites are at startup of Jetty.
|
||||
____
|
||||
|
||||
Some other Include / Exclude examples:
|
||||
Additional Include / Exclude examples:
|
||||
|
||||
Example: Include all ciphers which support https://en.wikipedia.org/wiki/Forward_secrecy[Forward Secrecy] using regex:
|
||||
*Example*: Include all ciphers which support https://en.wikipedia.org/wiki/Forward_secrecy[Forward Secrecy] using regex:
|
||||
|
||||
[source, xml, subs="{sub-order}"]
|
||||
----
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
[[setting-port80-access]]
|
||||
=== Setting Port 80 Access for a Non-Root User
|
||||
|
||||
On Unix-based systems, port 80 is protected; typically only the superuser root can open it. For security reasons, it is not desirable to run the server as root.
|
||||
This page presents several options to access port 80 as a non-root user, including using ipchains, iptables, Jetty's SetUID feature, xinetd, and the Solaris 10 User Rights Management Framework.
|
||||
On Unix-based systems, port 80 is protected; typically only the superuser `root` can open it. For security reasons, it is not desirable to run the server as `root`.
|
||||
This page presents several options to access port 80 as a non-root user, including using `ipchains`, `iptables`, Jetty's SetUID feature, `xinetd`, and the Solaris 10 User Rights Management Framework.
|
||||
|
||||
[[using-ipchains]]
|
||||
==== Using ipchains
|
||||
|
||||
On some Linux systems you can use the _ipchains REDIRECT_ mechanism to redirect from one port to another inside the kernel (if ipchains is not available, then usually iptables is):
|
||||
On some Linux systems you can use the _ipchains REDIRECT_ mechanism to redirect from one port to another inside the kernel (if `ipchains` is not available, then `iptables` usually is):
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -31,14 +31,14 @@ On some Linux systems you can use the _ipchains REDIRECT_ mechanism to redirect
|
|||
----
|
||||
|
||||
This command instructs the system as follows: "Insert into the kernel's packet filtering the following as the first rule to check on incoming packets: if the protocol is TCP and the destination port is 80, redirect the packet to port 8080".
|
||||
Be aware that your kernel must be compiled with support for ipchains (virtually all stock kernels are).
|
||||
You must also have the ipchains command-line utility installed.
|
||||
Be aware that your kernel must be compiled with support for `ipchains` (virtually all stock kernels are).
|
||||
You must also have the `ipchains` command-line utility installed.
|
||||
You can run this command at any time, preferably just once, since it inserts another copy of the rule every time you run it.
|
||||
|
||||
[[using-iptables]]
|
||||
==== Using iptables
|
||||
|
||||
On many Linux systems you can use the iptables REDIRECT mechanism to redirect from one port to another inside the kernel (if iptables is not available, then usually ipchains is).
|
||||
On many Linux systems you can use the `iptables` REDIRECT mechanism to redirect from one port to another inside the kernel (if `iptables` is not available, then usually `ipchains` is).
|
||||
|
||||
You need to add something like the following to the startup scripts or your firewall rules:
|
||||
|
||||
|
@ -47,8 +47,8 @@ You need to add something like the following to the startup scripts or your fire
|
|||
# /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
|
||||
----
|
||||
|
||||
The underlying model of iptables is different from ipchains, so the forwarding normally happens only to packets originating off-box.
|
||||
You also need to allow incoming packets to port 8080 if you use iptables as a local firewall.
|
||||
The underlying model of `iptables` is different from `ipchains`, so the forwarding normally happens only to packets originating outside of the server itself.
|
||||
You also need to allow incoming packets to port 8080 if you use `iptables` as a local firewall.
|
||||
|
||||
Be careful to place rules like this one early in your _input_ chain.
|
||||
Such rules must precede any rule that accepts the packet, otherwise the redirection won't occur.
|
||||
|
@ -57,16 +57,16 @@ You can insert as many rules as required if your server needs to listen on multi
|
|||
[[configuring-jetty-setuid-feature]]
|
||||
==== Configuring Jetty's SetUID Feature
|
||||
|
||||
http://en.wikipedia.org/wiki/Setuid[SetUID] is a technique that uses Unix-like file system access right to allow users to run an executable that would otherwise require higher privileges.
|
||||
http://en.wikipedia.org/wiki/Setuid[SetUID] is a technique that uses Unix-like file system access rights to allow users to run an executable that would otherwise require higher privileges.
|
||||
|
||||
Jetty's `SetUID` module allows you to run Jetty as a normal user even when you need to run Jetty on port 80 or 443.
|
||||
|
||||
To use it with the Jetty distribution:
|
||||
|
||||
1. Ensure that you have the `http.mod` (and link:#quickstart-starting-https[https.mod] if you are using SSL) link:#startup-modules[modules enabled] for the link:#creating-jetty-base[base] you are using.
|
||||
. Ensure that you have the `http.mod` (and link:#quickstart-starting-https[https.mod] if you are using SSL) link:#startup-modules[modules enabled] for the link:#creating-jetty-base[base] you are using.
|
||||
The `http.mod` is enabled by default in the distribution, while the link:#quickstart-starting-https[https.mod] is only enabled in the link:#demo-webapps-base[demo-base] directory.
|
||||
2. Ensure that you have link:#quickstart-changing-jetty-port[changed the http port] to 80 (and link:#quickstart-changing-https-port[changed the https port] to 443 if you are using SSL).
|
||||
3. Enable the `setuid.mod` module:
|
||||
. Ensure that you have link:#quickstart-changing-jetty-port[changed the http port] to 80 (and link:#quickstart-changing-https-port[changed the https port] to 443 if you are using SSL).
|
||||
. Enable the `setuid.mod` module:
|
||||
+
|
||||
[source, screen, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -76,16 +76,17 @@ The `http.mod` is enabled by default in the distribution, while the link:#quicks
|
|||
____
|
||||
[NOTE]
|
||||
The --add-to-start command will enable the setuid module for this and all subsequent executions of jetty.
|
||||
There are other ways to enable the module, such as just for this execution.
|
||||
There are other ways to enable the module, such as for a single execution.
|
||||
For more information on the alternatives see the section on link:#startup-modules[Managing Startup Modules].
|
||||
____
|
||||
4. Edit the configuration for the `setuid` module to substitute the `userid` and `groupid` of the user to switch to after starting.
|
||||
If you used the `--add-to-start` command, this configuration is in the `start.ini` file.
|
||||
If you used the `--add-to-startd` command instead, this configuration is in the `start.d/setuid.ini `file instead.
|
||||
|
||||
Here are the lines to configure:
|
||||
. Edit the configuration for the `setuid` module to substitute the `userid` and `groupid` of the user to switch to after starting.
|
||||
If you used the `--add-to-start` command, this configuration is in the `start.ini` file.
|
||||
If you used the `--add-to-startd` command instead, this configuration is in the `start.d/setuid.ini` file instead.
|
||||
|
||||
Below are the lines to configure:
|
||||
+
|
||||
[source,text]
|
||||
[source, text, subs="{sub-order}"]]
|
||||
----
|
||||
jetty.startServerAsPrivileged=false
|
||||
jetty.username=foo
|
||||
|
@ -95,11 +96,11 @@ jetty.umask=002
|
|||
+
|
||||
____
|
||||
[NOTE]
|
||||
As well as opening the connectors as root, you can also have jetty start the Server as root before changing to the non-root user.
|
||||
As well as opening the connectors as `root`, you can also have Jetty start the Server as `root` before changing to the non-`root` user.
|
||||
____
|
||||
|
||||
5. You now need a native code library to do the user switching.
|
||||
This code is hosted as part of the Jetty ToolChain project and it is released independently from Jetty itself.
|
||||
. A native code library is required to perform user switching.
|
||||
This code is hosted as part of the Jetty ToolChain project and is released independently from Jetty itself.
|
||||
You can find the source code https://github.com/eclipsejetty.toolchain[here] in the https://github.com/eclipse/jetty.toolchain/jetty-setuid[jetty-setuid] project.
|
||||
Build it locally, which will produce a native library appropriate for the operating system:
|
||||
+
|
||||
|
@ -110,9 +111,10 @@ Build it locally, which will produce a native library appropriate for the operat
|
|||
+
|
||||
If you built on a linux machine you will find the native library in `jetty-setuid/libsetuid-linux/target/libsetuid-linux.so`.
|
||||
If you built on a different operating system you will find the library in a different subdirectory, with the name containing the name of the operating system.
|
||||
You might like to copy this file into your jetty distribution's lib directory.
|
||||
6. Start jetty as the root user in your base directory, providing the location of the native library to java.
|
||||
Here's an example of how to do it on the command line, assuming were are in the link:#demo-webapps-base[demo-base] directory:
|
||||
You may want copy this file into your Jetty distribution's lib directory.
|
||||
|
||||
. Start Jetty as the `root` user in your base directory, providing the location of the native library to Java.
|
||||
Below is an example of how to do it from the command line, assuming you are in the link:#demo-webapps-base[demo-base] directory:
|
||||
+
|
||||
[source, screen, subs="{sub-order}"]
|
||||
----
|
||||
|
@ -120,6 +122,7 @@ Here's an example of how to do it on the command line, assuming were are in the
|
|||
----
|
||||
|
||||
[[using-solaris10-user-rights-management-framework]]
|
||||
|
||||
==== Using the Solaris 10 User Rights Management Framework
|
||||
|
||||
Solaris 10 provides a User Rights Management framework that can permit users and processes superuser-like abilities:
|
||||
|
|
|
@ -58,21 +58,21 @@ Otherwise, create a `webapps/myapp.xml` file as follows:
|
|||
</Configure>
|
||||
----
|
||||
|
||||
==== Preconfiguring the web application
|
||||
|
||||
If the `QuickStateWebApp` method `setAutoPreconfigure(true)` is called (see example in myapp.xml above), then the first time the webapp is deployed a `WEB-INF/quickstart-web.xml` file will be generated that contains the effective `web.xml` for all the discovered configuration.
|
||||
On subsequent deployments, all the discovery steps are skipped and the `quickstart-web.xml` is used directly to configure the web application.
|
||||
|
||||
It is also possible to preconfigure a war file manually by running the class link:{JDURL}/org/eclipse/jetty/quickstart/PreconfigureQuickStartWar.html[org.eclipse.jetty.quickstart.PreconfigureQuickStartWar] with the jetty-all-uber (aggregate) jar:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
----
|
||||
$ java -cp jetty-all-{VERSION}-uber.jar org.eclipse.jetty.quickstart.PreconfigureQuickStartWar myapp.war
|
||||
----
|
||||
|
||||
This will create the `quickstart-web.xml` file before the first deployment.
|
||||
Note that this can also be a good debugging tool for discovered configuration and if run with debug turned on the origin of every element is included in the `quickstart-web.xml` file.
|
||||
Run the class with no arguments to see other runtime options.
|
||||
// ==== Preconfiguring the web application
|
||||
//
|
||||
// If the `QuickStateWebApp` method `setAutoPreconfigure(true)` is called (see example in myapp.xml above), then the first time the webapp is deployed a `WEB-INF/quickstart-web.xml` file will be generated that contains the effective `web.xml` for all the discovered configuration.
|
||||
// On subsequent deployments, all the discovery steps are skipped and the `quickstart-web.xml` is used directly to configure the web application.
|
||||
//
|
||||
// It is also possible to preconfigure a war file manually by running the class link:{JDURL}/org/eclipse/jetty/quickstart/PreconfigureQuickStartWar.html[org.eclipse.jetty.quickstart.PreconfigureQuickStartWar] with the jetty-all-uber (aggregate) jar:
|
||||
//
|
||||
// [source, screen, subs="{sub-order}"]
|
||||
// ----
|
||||
// $ java -cp jetty-all-{VERSION}-uber.jar org.eclipse.jetty.quickstart.PreconfigureQuickStartWar myapp.war
|
||||
// ----
|
||||
//
|
||||
// This will create the `quickstart-web.xml` file before the first deployment.
|
||||
// Note that this can also be a good debugging tool for discovered configuration and if run with debug turned on the origin of every element is included in the `quickstart-web.xml` file.
|
||||
// Run the class with no arguments to see other runtime options.
|
||||
|
||||
==== Avoiding TLD Scans with precompiled JSPs
|
||||
|
||||
|
|
Loading…
Reference in New Issue