How can I do a 301 redirect from http to https in Wildfly 8.2?
Asked Answered
E

1

2

My web.xml has the following security constraint:

<security-constraint> 
    <web-resource-collection>     
        <web-resource-name>App</web-resource-name> 
        <url-pattern>/*</url-pattern>
    </web-resource-collection> 
    <user-data-constraint> 
        <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint>

This configuration redirects all http URLs to https via 302 redirects. Is there a way to accomplish the same except via 301 redirects in Wildfly 8.2?

Environment answered 7/10, 2015 at 14:41 Comment(5)
The only thing I can think of is to edit undertow itself....no idea how to do that though.Illume
You indeed need a custom ServletExtension. I only can't tell implementation detail from top of head right now.Politicize
@BalusC, I'll take a look at this approach. I'd appreciate it if you can find the time to provide an example. Until then I'll keep reading.Environment
Have you found an answer to this question in the meantime @Environment ?Slimy
@Thermometer, still no answer unfortunately. If I do find one, I'll be sure to post it.Environment
C
0

One way I can think of is using Predicates based handlers in undertow. See the example in the link below:

https://http2.undertow.io/documentation/core/predicates-attributes-handlers.html

The example explains a configurable 302 response based on request path. I think you can tweak it to return 301.

Cowden answered 23/10, 2015 at 7:10 Comment(1)
Does that really work on j_security_check too? I don't think so. Or have you tried it yourself?Politicize

© 2022 - 2024 — McMap. All rights reserved.