Redirecting behind a proxy leads to localhost address

390 views
Skip to first unread message

Ron Gross

unread,
Jan 16, 2012, 8:02:05 AM1/16/12
to play-fr...@googlegroups.com
I have a Play server behind an Apache frontend with mod-proxy acting as a reverse proxy.

In Secure module, I'm getting to this method with `url == null`:

    static void redirectToOriginalURL() throws Throwable {
        Security.invoke("onAuthenticated");
        String url = flash.get("url");
        if(url == null) {
            url = "/";
        }
        redirect(url);
    }

Now, even though I am browsing to http://mysite.com/prefix/secure/login, after a successful login I am redirected to http://localhost:9000/ - for some reason I'm switched to my own personal dev server instead of the production server. What could be the cause, and how to fix?

Alexander Reelsen

unread,
Jan 16, 2012, 12:35:11 PM1/16/12
to play-fr...@googlegroups.com
Hi

Ron Gross wrote:
> I have a Play server behind an Apache frontend with mod-proxy acting as
> a reverse proxy.

Have you read
http://www.playframework.org/documentation/1.2.4/production#SetupwithApache

and changed your setup that way?


--Alexander

Ron Gross

unread,
Jan 18, 2012, 7:20:37 AM1/18/12
to play-fr...@googlegroups.com
Thanks, I added the missing elements to my setup and this solved my problem.

Anthony

unread,
Jan 16, 2012, 9:01:48 AM1/16/12
to play-framework
Had this same issue with nginx. Did you set the ProxyPass and
ProxyPassReverse in Apache?

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

<Proxy *>Order deny,allowAllow from all</Proxy>
ProxyPass /foo http://foo.example.com/barProxyPassReverse /foo
http://foo.example.com/bar

This is the gist of the nginx configuration:

location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 http://www.example.com;
}

- Anthony

On Jan 16, 8:02 am, Ron Gross <ron.gr...@gmail.com> wrote:
> I have a Play server behind an Apache frontend with mod-proxy acting as a
> reverse proxy.
>
> In Secure module, I'm getting to this method with `url == null`:
>
>     static void redirectToOriginalURL() throws Throwable {
>         Security.invoke("onAuthenticated");
>         String url = flash.get("url");
>         if(url == null) {
>             url = "/";
>         }
>         redirect(url);
>     }
>
> Now, even though I am browsing tohttp://mysite.com/prefix/secure/login,
> after a successful login I am redirected tohttp://localhost:9000/- for

Ron Gross

unread,
Jan 18, 2012, 4:27:36 PM1/18/12
to play-fr...@googlegroups.com
I followed the instructions to the letter (don't remember the exact config right now, can check if you want).

tl;dr:

I'm not a big Apache guy - I used the default Apache config, and it worked well except for this glitch, and when I applied the recommended settings from the play framework page, it worked flawlessly.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.




--

Reply all
Reply to author
Forward
0 new messages