Fork me on GitHub
#ring
<
2017-03-05
>
sova-soars-the-sora19:03:34

@weavejester hm. well thank you for your help, i must be having another issue then. i still get https://localhost when trying to access my domain over ze web

weavejester19:03:13

Have you ensured that the x-forwarded-for header is set by the proxy, @sova

sova-soars-the-sora19:03:33

Have not yet... I'm not sure how I would go about that. you mean by (in this case) apache2 and not by ring/server.clj ?

weavejester19:03:31

Yeah, the server you’re proxying from needs to set certain headers. X-Forwarded-For and X-Forwarded-Proto I believe.

weavejester19:03:04

Although I think the Host header should be sufficient for the redirect.

sova-soars-the-sora19:03:05

Hmm well that's excellent to know, that helps tremendously... now I just gotta find out how to set that up to happen

weavejester19:03:27

What are you using as a proxy?

sova-soars-the-sora19:03:56

My setup is: lein start gets a localhost:56162 [some port] going... I have an apache2.4.7 install and I'm just using simple ProxyPass directives to redirect my domain name to localhost:/56162 ...

sova-soars-the-sora19:03:15

I just changed something (ProxyPreserveHost) and now I get a different message: site not working, redirected you too many times.

weavejester19:03:37

So ProxyPreserveHost sounds like it fixed your Host header problem.

weavejester19:03:56

Before, your site was being told that the Host was localhost, hence the erroneous redirection.

weavejester19:03:21

Now I suspect that its not setting X-Forwarded-Proto, so your site doesn’t know whether it’s getting HTTPS

weavejester19:03:32

So it just gets HTTP each time, and redirects forever.

weavejester19:03:09

You might need to add:

RequestHeader set X-Forwarded-Proto https

weavejester20:03:18

Although if you allow HTTP as well, maybe $scheme. Not sure how it works in Apache - I usually use nginx.

weavejester20:03:31

I guess in Apache you just set it to “http” on your :80 config, and “https” on your :443 config

sova-soars-the-sora20:03:38

I had to enable the request header module using sudo a2enmod headers and ... now it works.

sova-soars-the-sora20:03:53

The site loads over https:// which is sweet!

sova-soars-the-sora20:03:08

But my sente sockets are still not working, and my /login page is 403 forbidden via ajax

sova-soars-the-sora20:03:32

but hey, thanks a lot for your help thusfar. seems like it just needs a few more tweaks. nginx might be a much better way to go at this point... will see

weavejester20:03:59

Not sure how Apache proxies websockets.

weavejester20:03:23

I only vague recall how nginx does it. I do remember you need extra configuration for nginx though.

sova-soars-the-sora21:03:25

mother-effing stack overflow ftw

sova-soars-the-sora21:03:29

RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)            [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)            [P,L]

sova-soars-the-sora21:03:44

whatever i never have to look at that file again. i'm glad it works xD

sova-soars-the-sora21:03:59

@weavejester thanks a tonnne for your help homie

weavejester21:03:24

No problem. Glad you got it sorted 🙂