0

my website use cloudflare. It has two parts: 1 - api, made with php 2 - frontend, nuxt js reverse proxy

I use Cloudflare's "CF-IPCountry" header in order to detect the client country code. If I access directly to my api from the web browser, the header is correct.

But if my frontend make a Server Side Rendering request to my api, the header is wrong and takes the country of the hosting.

Here is my apache config:

<VirtualHost *:443>
        ServerName mywebsite.com
        ProxyPass / http://127.0.0.1:3000/
        ProxyPassReverse / http://127.0.0.1:3000/
        ProxyPreserveHost On

        RewriteEngine On
        RewriteCond %{HTTP_HOST} !^mywebsite.com$
        RewriteRule ^/?(.*) https://mywebsite.com/$1 [QSA,R=301,L]

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

        SSLCertificateFile /etc/letsencrypt/live/mywebsite.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mywebsite.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

<VirtualHost *:443>
        ServerName api.mywebsite.com
        DocumentRoot "/var/www/mywebsite-api/public"

        RewriteEngine On

        RemoteIPHeader X-Forwarded-For
        <Directory /var/www/mywebsite-api/public>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        SSLCertificateFile /etc/letsencrypt/live/mywebsite.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mywebsite.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
lengas
  • 1

0 Answers0