Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify HTTP configuration #3840

Merged
merged 15 commits into from
Oct 5, 2017
Merged

Simplify HTTP configuration #3840

merged 15 commits into from
Oct 5, 2017

Conversation

joschi
Copy link
Contributor

@joschi joschi commented May 17, 2017

Motivation and Context

Users regularly have problems finding the correct settings for the Graylog REST API and Graylog web interface listeners in their environments.

This change set tries to simplify the network settings for the Graylog HTTP interfaces (Graylog REST API and web interface).

The two separate network listeners for the Graylog REST API and the Graylog web interface have been merged, vastly reducing the necessary configuration settings.

While the the Graylog REST API and the Graylog web interface could be configured separately via the rest_listen_uri and web_listen_uri settings in the past, they now run on the same network listener which can be configured via http_bind_address.

The context path for the Graylog REST API is now hard-coded to /api.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@philicious
Copy link

while I never had bigger problems with it, these "duplicate" settings were indeed a little confusing and I like this change 👍

@joschi joschi force-pushed the simplify-http-configuration branch from 44c6978 to 28aa7f3 Compare June 13, 2017 12:35
@bernd bernd added this to the 3.0.0 milestone Sep 28, 2017
@kroepke kroepke self-requested a review September 28, 2017 09:41
@kroepke kroepke self-assigned this Sep 28, 2017
@joschi joschi force-pushed the simplify-http-configuration branch from 28aa7f3 to 1c6a4ae Compare October 2, 2017 12:09
Copy link
Member

@kroepke kroepke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks much better than the situation before!

I have a few minor nitpicks, regarding methods and constants and only one issue regarding IPv6 wildcard address handling.
That's probably more of an edge case, but at least we should return a valid IP address in that case.

UPGRADING.rst Outdated
+---------------------------------+----------------------------------+--------------------+
| ``web_max_initial_line_length`` | ``http_max_initial_line_length`` | ``4096`` |
+---------------------------------+----------------------------------+--------------------+
| ``web_thread_pool_size`` | ``http_thread_pool_size`` | ``false`` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 16 I guess

public HostAndPort getHttpBindAddress() {
return httpBindAddress
.requireBracketsForIPv6()
.withDefaultPort(9000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also use the constant GRAYLOG_DEFAULT_PORT

return getUriScheme(isHttpEnableTls());
}

public String getUriScheme(boolean enableTls) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only used once in the method above and could be inlined.

}

@VisibleForTesting
URI getDefaultHttpUri(String path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be private as it is not directly used in tests (only via its two private usages)

null,
bindAddress.getHost(),
bindAddress.getPort(),
"/",
null,
null
);

apiHttpServer = setUp("rest",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix is now unused and always "rest" so I think we can rid of the parameter.

final HostAndPort bindAddress = getHttpBindAddress();

final URI publishUri;
if (WILDCARD_IP_ADDRESS.equals(bindAddress.getHost())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently does not take the IPv6 wildcard address into account and will publish [::] as the URI, which is invalid.
I think that adding a check against [::] and extending Tools.guessPrimaryNetworkAddress() to also look for IPv6 addresses, would be the best option here.

final URI defaultHttpUri = getDefaultHttpUri();
LOG.debug("No \"http_publish_uri\" set. Using default <{}>.", defaultHttpUri);
return defaultHttpUri;
} else if (WILDCARD_IP_ADDRESS.equals(httpPublishUri.getHost())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not take the IPv6 wildcard address into account: [::]. See below for another instance of that.

@joschi joschi force-pushed the simplify-http-configuration branch from d4bb107 to 80f50c3 Compare October 4, 2017 09:35
@kroepke
Copy link
Member

kroepke commented Oct 4, 2017

With the latest changes I get the error message:

We are experiencing problems connecting to the Graylog server running on http://[fe80:0:0:0:b8dd:21ff:fe2f:35c0%veth3415fad]:9000/api/. Please verify that the server is healthy and working correctly.

When using http_bind_address = [::].
Investigating.

@joschi joschi force-pushed the simplify-http-configuration branch from 80f50c3 to 9500a81 Compare October 4, 2017 14:19
@joschi
Copy link
Contributor Author

joschi commented Oct 4, 2017

@kroepke I guess fe80:0:0:0:b8dd:21ff:fe2f:35c0%veth3415fad is simply the first IPv6 address of the first network interface in the system (for random values of "first").

I'm not convinced that this approach (that worked reasonably well for IPv4) is suitable for IPv6. 🤔

@kroepke
Copy link
Member

kroepke commented Oct 5, 2017

Nevermind, this was due to automatically binding to a different interface. Works as expected.

@kroepke
Copy link
Member

kroepke commented Oct 5, 2017

Looks good, thanks for the rebase and implementing this!

@kroepke kroepke merged commit ac21a44 into master Oct 5, 2017
@kroepke kroepke deleted the simplify-http-configuration branch October 5, 2017 07:55
@joschi joschi removed the in progress label Oct 6, 2017
joschi pushed a commit that referenced this pull request Oct 6, 2017
The old options got removed and the user has to change her config to the new one.

Refs #3840
edmundoa pushed a commit that referenced this pull request Oct 25, 2017
Some URLs require some search query parameters to be set, and this
stopped working since #3840.

Fixes #4290
bernd pushed a commit that referenced this pull request Nov 1, 2017
* Include query and hash params in qualified URLs

Some URLs require some search query parameters to be set, and this
stopped working since #3840.

Fixes #4290

* Use string templates instead of concatenating

* Add Routes tests

- Test routes with prefix
- Test routes with no prefix
- Ensure search query parameters are not removed from routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants