0

What is the easiest way to redirect from HTTP to HTTPS in Quarkus?

I've searched the config documentation https://quarkus.io/guides/all-config but couldn't find anything.

I tried to add the undertow dependency and a web.xml to force a https connection. The web.xml I added looks like this:

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <security-constraint> <web-resource-collection> <web-resource-name>All</web-resource-name> <url-pattern>*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> </web-app>

Dan Kiva
  • 1
  • 2

1 Answers1

0

First how to create certificate and give to quarkus. you can see details about in this answer.

The problem is mvn quarkus:dev does not work with SSL. I got Caused by: java.nio.file.NoSuchFileException: .\keystore.jks but good news normal java -jar runs correctly. how to run java jar

Here is the configuration you are looking for more precisely quarkus.http.insecure-requests=redirect it does not work without providing a certificate. You can see how did I create the certificate here

Screen capture to show how it works in firefox, check the bottom dev console. How looks oon firefox

And last but not least here is a running example https://github.com/ozkanpakdil/quarkus-examples/tree/master/local-ssl-usage

ozkanpakdil
  • 3,199
  • 31
  • 48