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

Add "--use-http-x-forwarded-for" option for NGINX #277

Open
wants to merge 1 commit into
base: 3.x-dev
Choose a base branch
from

Conversation

adityapahuja
Copy link

This pull request

  • updates the script to pick up an ip address from the http_x_forwarded_for field instead of the ip field in NGINX JSON formatted log file provided that the "--use-http-x-forwarded-for" option is used. If the http_x_forwarded_for field contains "-" or is missing, the script will pick up the ip address from the ip field. This option is useful if the ip field does not contain client's ip address (e.g. using NGINX as a reverse proxy).
  • updates README file to include a field http_x_forwarded_for in NGINX log file and information about the usage of "--use-http-x-forwarded-for" option.
  • adds two test cases to test the "--use-http-x-forwarded-for" option to ensure that the script works properly.

This feature is useful for replaying requests coming from NGINX reverse proxy to Matomo.

Updated the script to pick up an ip address from the `http_x_forwarded_for`
field instead of the `ip` field in NGINX JSON formatted log file provided that
the "--use-http-x-forwarded-for" option is used.  If the `http_x_forwarded_for`
field contains "-" or is missing, the script will pick up the ip address from
the `ip` field. This option is useful if the `ip` field does not contain
client's ip address (e.g. using NGINX as a reverse proxy).
Updated README file to include a field `http_x_forwarded_for` in NGINX
log file and information about the usage of "--use-http-x-forwarded-for" option.
Added two test cases to test the "--use-http-x-forwarded-for" option to ensure
that the script works properly.
@kutovoys
Copy link

@adityapahuja Thank you! That helped me.

@@ -891,6 +900,11 @@ def _create_parser(self):
default=False,
help="Do not verify the SSL / TLS certificate when contacting the Matomo server. This is the default when running on Python 2.7.8 or older."
)
option_parser.add_option(

Choose a reason for hiding this comment

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

For new versions it will be
parser.add_argument(

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.

2 participants