Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Thredds do not behave well behind Nginx proxy serving as SSL termination #1310

@tlvu

Description

@tlvu

This is our Nginx proxy config. We are using Nginx to provide SSL termination.

    location /thredds/ {
        proxy_pass http://thredds:8080/thredds/;
        proxy_set_header Host $host;  # pass the original public hostname to Thredds
        proxy_set_header X-Forwarded-Proto $scheme;  # pass the original httpS proto to Thredds
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  # pass the original client IP to Thredds
    }

We are using docker image unidata/thredds-docker:4.6.14.

What we found out is Thredds is ignoring the X-Forwarded-Proto http header and the X-Forwarded-For http header as well since in the logs, we only see IP of our Nginx proxy.

Below we see the IP 172.21.0.1 which is the Nginx proxy, not the real client IP requesting data from Thredds. It's the same IP everywhere.

$ docker exec -it thredds grep 'Remote host' /usr/local/tomcat/content/thredds/logs/threddsServlet.log | tail -1
2019-09-19T20:49:01.911 +0000 [   4657961][     144] INFO  - threddsServlet - Remote host: 172.21.0.1 - Request: "GET /twitcher/ows/proxy/thredds/catalog.html HTTP/1.1"

The original public hostname is preserved by Thredds so the Host http header seems to be honored properly.

2019-09-16-180801_1014x481_scrot

To work-around the X-Forwarded-Proto http header not being honored, we added scheme="https" to the Connector in server.xml:

    <Connector scheme="https" server="Apache" secure="true" port="80
80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

That server.xml file is from the docker image so we had to insert an entrypoint to modify that file right before the regular startup.

We still have no work-around for the wrong client IP being logged because X-Forwarded-For http header is being ignored.

Also, using Nginx as a reverse proxy should be documented here https://www.unidata.ucar.edu/software/tds/current/reference/TomcatBehindProxyServer.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions