By AlexS


2018-04-16 11:15:12 8 Comments

I have a small problem with redirecting everything from http to https. Here is the setup of my environment:

The server is a docker host which runs multiple docker containers. I'm trying to access a container that listens on port 9000. so I have a ProxyPass in the vhost file that looks like this:

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName subdomain.domain.com
    ProxyPass / http://localhost:9000/
    ProxyPassReverse / http://localhost:9000/
    Redirect / https://subdomain.domain.com/
</VirtualHost>

The SSL Certificate is issued by AWS. This server is behind a AWS Load Balancer. From the load balancer I have 2 target groups. One is redirecting 80 to 80, and the other 443 to 443.

Right now the https://subdomain.domain.com is throwing 502 bad gateway error.

Could someone have any idea what the issue here might be? Thanks in advance!

2 comments

@AlexS 2018-04-16 13:14:21

I've tried adding this to the vhosts file:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{subdomain.domain.com/}%{REQUEST_URI} [L,R=permanent]

as indicated in the aws documentation. It doesn't work, I get an error saying invalid redirect. No idea what the problem is.

Anyone else experienced this problem?

@GE ownt 2018-04-16 11:21:08

Does this help: https://www.namecheap.com/support/knowledgebase/article.aspx/9821/38/redirect-to-https-on-apache?
It seems like you need to redirect permanent.

@AlexS 2018-04-16 11:30:21

I've changed the target groups. Created only one, HTTP on port 80. And added 2 listeners on the load balancer, one 80 and one 443 both set on the same target group. Now, http and https work. But the redirect is not happening. I've enabled mod_rewrite, mod_ssl, I'm thinking something in my vhosts.conf is wrong.

Related Questions

Sponsored Content

9 Answered Questions

[SOLVED] HTTP status code for update and delete?

31 Answered Questions

[SOLVED] How to manage a redirect request after a jQuery Ajax call

59 Answered Questions

[SOLVED] How do I redirect to another webpage?

27 Answered Questions

[SOLVED] How to make a redirect in PHP?

  • 2009-04-20 14:13:22
  • Sam
  • 2138518 View
  • 973 Score
  • 27 Answer
  • Tags:   php redirect

2 Answered Questions

[SOLVED] Redirecting AWS ELB HTTP Requests to HTTPS

3 Answered Questions

[SOLVED] HTTP to HTTPS Redirects for AWS ELB and Tomcat7 server

1 Answered Questions

1 Answered Questions

1 Answered Questions

[SOLVED] Glassfish HTTPS redirect behind SSL offloader and Apache

Sponsored Content