1

Because of Same Origin Policy, I want to send my form via a proxy to another website. So add this to virtual host configuration:

ProxyPass /submit http://another.website.com/
ProxyPassReverse /submit http://another.website.com/

That works. And my form successfully posted with no errors. But, there are 2 problems:

  1. cookies don't go with the request. I want to include cookies related to another.website.com with my AJAX request.

  2. I set a cookie in destination page (which I post my form via a proxy to it), with this code:

    setcookie("TestCookie", "blah blah", time() + 3600, '/', '.another.website.com');
    

    but, when try to get that cookie on http://another.website.com/search, I can't find this. and $_COOKIE['TestCookie'] is NULL. (Firebug also doesn't show that cookie)

Edit: 2nd problem solved. (I can't set cookie for another domain, what I did).

Edit: The form is on "localhost", and I want to submit it to "another.website.com".

Community
  • 1
  • 1
mrdaliri
  • 7,148
  • 22
  • 73
  • 107
  • 2
    You need to rewrite the cookie domain/paths, too. That is supported by Apache, please check the exact same proxy section in the httpd docs: [`ProxyPassReverseCookieDomain` Directive](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreversecookiedomain) and [`ProxyPassReverseCookiePath` Directive](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreversecookiepath) – hakre Dec 16 '12 at 22:32
  • @hakre: rewrite paths to what path? `/` to `/`? Could you give me an example? (I read `ProxyPassReverseCookiePath` section, and tried it, but problem didn't solve) – mrdaliri Dec 16 '12 at 22:36
  • If path is the same it needs no change obviously. In that case only change the cookie **domain** (see first linked directive: [`ProxyPassReverseCookieDomain` Directive](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreversecookiedomain)). – hakre Dec 16 '12 at 22:37
  • @hakre: OK, now all cookies with domain "localhost", are sent with request, and their domain has changed to "another.website.com". But I want to send cookies which their domain is "another.website.com"; not all "localhost" cookies. – mrdaliri Dec 16 '12 at 22:40
  • Please add the two hostnames to your question: 1.) Frontend Server (public-domain; currently *unknown*) 2.) Backend Server (internal-domain; currently *another.website.com*). Which one is 1.)? *localhost* is not valid in this context. Also please see the examples given in http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse – hakre Dec 16 '12 at 22:41
  • @hakre: I tried that example, but problem 2 happened. – mrdaliri Dec 16 '12 at 22:55
  • Problem 2? I have no clue what problem 2 is. Also still open: **What is the public domain?** Add your complete directives to the question. – hakre Dec 16 '12 at 22:58
  • @hakre: I edited question. I'm on localhost, and try to post form to another.website.com. Please review my question. I wrote 2 problems: 1, I can't post cookies, 2, I can't write cookies. – mrdaliri Dec 16 '12 at 23:00
  • 2nd problem solved. (I can't set cookie for another domain), now, the problem is how to send cookies with request which are related to another.website.com, not "localhost" – mrdaliri Dec 16 '12 at 23:11
  • That is why I ask all the time about the two hostnames. Localhost even technically is a correct hostname, it does not make much sense in this context. What is hostname of the server you send the HTTP request to with your browser? What is in the address bar? – hakre Dec 16 '12 at 23:16

0 Answers0