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

Fix geoserver not configured properly behind proxy #106

Merged
merged 2 commits into from
Nov 25, 2020

Conversation

tlvu
Copy link
Collaborator

@tlvu tlvu commented Nov 25, 2020

Hitting https://pavics.ouranos.ca/geoserver/wfs?request=GetCapabilities&version=1.1.0

Before fix (wrong scheme and wrong port):

<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
<ows:Post xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>

After fix:

<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="https://pavics.ouranos.ca:443/geoserver/wfs"/>
<ows:Post xlink:href="https://pavics.ouranos.ca:443/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>

This config automate manual step to set proxy base url in Geoserver UI https://docs.geoserver.org/2.9.3/user/configuration/globalsettings.html#proxy-base-url

I had to override the docker image entrypoint to edit the server.xml on the fly before starting Geoserver (Tomcat) since setting Java proxy config did not seem to work (see first commit).

Related to Ouranosinc/raven#297.

Edit:

  • Added "I had to override the docker image entrypoint to edit the server.xml on the fly before starting Geoserver (Tomcat) since setting Java proxy config did not seem to work (see first commit)."

…rick

As suggested here
https://serverfault.com/questions/177273/set-up-http-proxy-for-tomcat-web-server
and here https://memorynotfound.com/configure-http-proxy-settings-java/
using setenv.sh trick from
https://github.com/kartoza/docker-geoserver/tree/2.9.4#setting-tomcat-properties

Trying to fixing this problem:

Hitting directly geoserver http://pavics.ouranos.ca:8087/geoserver/wfs?request=GetCapabilities&version=1.1.0 (only works inside Ouranos firewall), I am getting proper
```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://pavics.ouranos.ca:8087/geoserver/wfs"/>
<ows:Post xlink:href="http://pavics.ouranos.ca:8087/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```

Behind Nginx proxy https://pavics.ouranos.ca/geoserver/wfs?request=GetCapabilities&version=1.1.0, we end up with the wrong http protocol and the wrong port
```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
<ows:Post xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```
…rking fix

Rollback fddbd1e.

Trying to fixing this problem:

Hitting directly geoserver http://pavics.ouranos.ca:8087/geoserver/wfs?request=GetCapabilities&version=1.1.0 (only works inside Ouranos firewall), I am getting proper
```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://pavics.ouranos.ca:8087/geoserver/wfs"/>
<ows:Post xlink:href="http://pavics.ouranos.ca:8087/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```

Behind Nginx proxy https://pavics.ouranos.ca/geoserver/wfs?request=GetCapabilities&version=1.1.0, we end up with the wrong http protocol and the wrong port
```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
<ows:Post xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```

With this fix:

Behind Nginx proxy https://lvupavics.ouranos.ca/geoserver/wfs?request=GetCapabilities&version=1.1.0 we get

```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="https://lvupavics.ouranos.ca:443/geoserver/wfs"/>
<ows:Post xlink:href="https://lvupavics.ouranos.ca:443/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```
Copy link
Collaborator

@huard huard left a comment

Choose a reason for hiding this comment

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

I approve the spirit of it, but cannot really comment on the actual content ; )

@tlvu
Copy link
Collaborator Author

tlvu commented Nov 25, 2020

FYI @f-PLT

Copy link
Contributor

@Zeitsperre Zeitsperre left a comment

Choose a reason for hiding this comment

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

I somehow understand this! And also it looks good to me.

@f-PLT
Copy link

f-PLT commented Nov 25, 2020

Great!

I'll pass this information along on our side.

@tlvu
Copy link
Collaborator Author

tlvu commented Nov 25, 2020

Great!

I'll pass this information along on our side.

Adding @matprov as well.

If CRIM instances have autodeploy enabled, there is nothing to do on your side, you'll just get it automatically.

@tlvu
Copy link
Collaborator Author

tlvu commented Nov 25, 2020

I somehow understand this! And also it looks good to me.

Sorry maybe I need to explain in simple terms what I did for everyone else as well.

I had to override the docker image entrypoint to edit the server.xml on the fly before starting Geoserver (Tomcat) since setting Java proxy config did not seem to work (see first commit).

@tlvu tlvu merged commit 0b473c7 into master Nov 25, 2020
@tlvu tlvu deleted the fix-geoserver-not-configured-properly-behind-proxy branch November 25, 2020 15:58
@matprov
Copy link
Collaborator

matprov commented Nov 25, 2020

If CRIM instances have autodeploy enabled, there is nothing to do on your side, you'll just get it automatically.

@tlvu Yes our staging has just been updated with this change, so prod will be updated tonight, thanks to autodeploy!

tlvu added a commit that referenced this pull request Mar 24, 2021
Restore this fix:
#106, adapt to new
entrypoint.

Tested setting env var `HTTPS_PROXY_NAME: ${PAVICS_FQDN_PUBLIC}`, as in
https://github.com/kartoza/docker-geoserver/blob/b3239c32da009dca57e15ffdb5c3f3a465184466/scripts/start.sh#L186-L188,
did not work.

Test:
```
$ curl --silent "https://lvupavicsmaster.ouranos.ca/geoserver/wfs?request=GetCapabilities&version=1.1.0" | xmllint --format - |grep lvupavicsmaster
<wfs:WFS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:inspire_dls="http://inspire.ec.europa.eu/schemas/inspire_dls/1.0" xmlns:inspire_common="http://inspire.ec.europa.eu/schemas/common/1.0" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs https://lvupavicsmaster.ouranos.ca/geoserver/schemas/wfs/1.1.0/wfs.xsd http://inspire.ec.europa.eu/schemas/inspire_dls/1.0 http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd" updateSequence="0">
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Get xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
          <ows:Post xlink:href="https://lvupavicsmaster.ouranos.ca/geoserver/wfs"/>
```
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