https reverse proxy on http jetty

5,242

Try adding the following to your HTTP connector in the Jetty application:

<Set name="forwarded">true</Set>

This will try to read the following headers that are supposed to be sent by the proxy:

  • X-Forwarded-For - The IP address of the client
  • X-Forwarded-Host - The original host requested by the client in the Host HTTP request header
  • X-Forwarded-Server - The hostname of the proxy server
  • X-Forwarded-Proto - The URL protocol scheme of the original request

If Apache does not send these headers and your host cannot make it send these headers, you will probably need to write a custom Connector, you can read more about that here.

Share:
5,242

Related videos on Youtube

David Portabella
Author by

David Portabella

Looking for a new job on Scala and ML in Zürich, or remotely. Senior Scala software engineer with interest in data engineering, familiar with scrum methodology. Four years of teaching experience on software engineering. PhD in Computer Science from Switzerland, and a Master of Telecommunications Systems from Barcelona. 43 years old Single Spanish and Swiss nationality [email protected] http://www.linkedin.com/in/dportabella http://stackoverflow.com/users/280393 https://github.com/dportabella Software developer Scala, Python Java, C/C++ (long time ago) Akka HTTP, Play, Anorm, a bit of Slick, Spark and Akka Front-end: Javascript/Typescript, ScalaJs, CSS3 Databases: MySQL, Oracle, h2database, MongoDB A bit of Machine learning and Natural Language Processing: Stanford NLP Conditional Random Fields with Wapiti R Statistical Computing Scala Spark classifiers Markov Logic Networks with Alchemy and LoMRF Word embedding with Gensim Tools Software tools: SBT, Maven, Bamboo, Sonar, Puppet Project management tools: JIRA, Trello Software development methodology: Scrum https://www.linkedin.com/in/dportabella

Updated on September 18, 2022

Comments

  • David Portabella
    David Portabella almost 2 years

    I have a jetty application on http. My web hosting runs a reverse proxy on apache on https, which proxies to my jetty application (http).

    browsing the first page (https://example.com/index.html) works, however when I click on a link, it falls back to http. (http://example.com/link.html, instead of https://example.com/link.html)

    how to solve this? is it a configuration issue on apache (which should rewrite the urls), or is it a configuration in jetty (I should configure something such as the "canonical url" in jetty?)

    actually I cannot change the configuration in apache (as only my webhosting provider has access to it), so I hope the issue can be solved on jetty. how to do so? note: my jetty needs to run on http (not on https), as defined by my webhosting provider.

  • David Portabella
    David Portabella almost 10 years
    thanks, your post gave me the right track! my jetty.xml file had this commented snipped: "<Call name="addCustomizer"><Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/‌​></Arg></Call>". the problem was solved by uncommenting this.