0

I'm using Apache to proxy all requests from my domain to my Odoo server.

Then to proxy all requests from my customers URLs to their respective databases (sub-domain of my domain).

Here's what my config looks like:

################
# welcome page #
################

<VirtualHost *:80>
    ServerName mydomain.fr
    ServerAlias www.mydomain.fr
    DocumentRoot /var/www/odoo
</VirtualHost>


#################
# wilcard proxy #
#################

<VirtualHost *:80>
    ServerName mydomain.fr
    ServerAlias *.mydomain.fr

    ErrorLog /var/log/odoo/odoo-error.log
    CustomLog /var/log/odoo/odoo-access.log combined
    LogLevel warn

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://mydomain.fr:8089/
    ProxyPassReverse / http://mydomain.fr:8089/

    ProxyVia On
</VirtualHost>


##################
# customer proxy #
##################

<VirtualHost *:80>
    ServerName customer-domain.fr
    ServerAlias www.customer-domain.fr

    ProxyRequests Off
    ProxyPass / http://customer-domain.mydomain.fr/
    ProxyPassReverse / http://customer-domain.mydomain.fr/

    ProxyVia On
</VirtualHost>


################
# restrictions #
################

<Location /web/database>
    Order deny,allow
    Deny from all
    Allow from 1.2.3.4
    Allow from 5.6.7.8
</Location>

Now, when I go to customer-domain.fr, after I click a few internal links, I'm redirected to customer-domain.fr, customer-domain.mydomain.fr.

Which is weird, because it's as if Apache somehow appended the target URL at the end of the source url of the proxy. I tried with Chrome, Firefox, and someone else house.

What causes this coma to appear, and how to prevent this ?


Update

I commented out the <Proxy *> section.

So, I did some tests with the console:

  • clear cache
  • go to customer-domain.fr -> no problem here, I receive a 200 response on the exact domain I requested.
  • click on English to change the language of the website : here are the headers :

    **General**
    Request URL:http://customer-domain.fr/website/lang/en_US?r=%2Fen_US%2Fpage%2Fhomepage
    Request Method:GET
    Status Code:303 SEE OTHER
    Remote Address:01.23.45.67:80
    
    **Response Headers**
    Connection:Keep-Alive
    Content-Encoding:gzip
    Content-Type:text/html; charset=utf-8
    Date:Fri, 13 Jan 2017 13:53:21 GMT
    Keep-Alive:timeout=10, max=100
    Location:http://customer-domain.fr, customer-domain.mydomain.fr/en_US/page/homepage
    Server:Werkzeug/0.8.3 Python/2.7.3
    Set-Cookie:website_lang=en_US; Path=/
    Set-Cookie:session_id=xxx; expires=Thu, 13-Apr-2017 13:53:21 GMT; Max-Age=7776000; Path=/
    Transfer-Encoding:chunked
    Vary:Accept-Encoding
    Via:1.1 mydomain.fr
    Via:1.1 customer-domain.fr
    
    **Request Headers**
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Encoding:gzip, deflate, sdch
    Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
    Cache-Control:no-cache
    Connection:keep-alive
    Cookie:website_lang=fr_FR; session_id=xxx
    Host:customer-domain.fr
    Pragma:no-cache
    Referer:http://customer-domain.fr/
    Upgrade-Insecure-Requests:1
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
    
    **Query String Parameters**
    r:/en_US/page/homepage
    
  • try installing mod_rewrite and add this directly under "ProxyRequest Off" - "RewriteEngine on" – Orphans Jan 13 '17 at 9:31
  • also, this should be added right below ProxyPassReverse: RewriteRule ^/$ http://%{HTTP_HOST}/ [L,R=301] – Orphans Jan 13 '17 at 9:37
  • I added that in the # wilcard proxy # section, but now I got a "Problem loading page" – Yann Jan 13 '17 at 9:43
  • I don't see how mod_rewrite is needed here and that rewrite may very well add a loop. I believe the key here is those links he clicks, exactly where do they point?, and the use of ProxyPreserveHost on. Also remove Proxy * entry if you don't want a forward proxy, as you seem you don't want when you are also using proxyrequests off. There is need for more specific detail here, and using mod_rewrite as a magic duct and tape recipe to workaround things is not the solution imho. Run away from mod_rewrite unless it is strictly necessary to use it. – ezra-s Jan 13 '17 at 11:20
  • Use the webconsole or a web browser or curl to know exactly when you get redirected like that, that detail is needed – ezra-s Jan 13 '17 at 11:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.