Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I want to run Presta behind an Nginx reverse proxy. Presta 8.2.1 is running on Nginx 1.26.3. I’ve prepared:

  • Reverse proxy config: https://pastebin.com/Xcx2s93f
  • Presta (backend) config: https://pastebin.com/q1V8y4zx
  • In Presta’s database, in the ps_shop_url table, I set the domain and domain_ssl columns to test-proxy.example.com and test-proxy.example.com respectively. By default, / in physical_uri.
  • Backoffice works perfectly. In it, under Shop Parameters → Traffic & SEO, I have:

Set up URLs:

  • Friendly URL → Yes
  • Redirect to the canonical URL → 302 Moved Temporarily

Set shop URL:

  • Shop domain → test-proxy.example.com
  • SSL domain → test-proxy.example.com
  • Base URI → /

The problem I deal with:
When I go to test-proxy.example.com, I get a redirect loop from test-proxy.example.com to test-proxy.example.com with a 302 status code. If I change the "Redirect to the canonical URL" option in the backoffice to 301, then I get a redirect loop with a 301 status code.

Visiting any non-existent URL, e.g. test-proxy.example.com/test, generates the correct response /index.php?controller=404.

Visiting any existing URL, e.g. test-example.com/about-us, causes a redirect loop: /about-us/ 302 → /about-us 302 → /about-us 302 → /about-us and so on in a loop.

If I only change in the database, in the above-mentioned table, test-proxy.example.com in both columns to presta-us.example.com, then the front works, but there’s a problem with the cart. This is understandable behavior.

Of course, when I completely delete reverse proxy, presta-us.example.com works smoothly like it should. :)

I have no idea what’s going on anymore. I checked the values of the headers passed by the proxy. I also prepared a script that displayed the header values: https://pastebin.com/tmT9R2Jd

The goal:
Working Prestashop front behind nginx reverse proxy.
I also set up Wordpress behind reverse proxy, which works - frontend/backoffice - like a charm.

You must be logged in to vote

Replies: 1 comment

Comment options

I tried with clean presta 8.2.1 and also 1.7.8.10. My config works perfectly front/backoffice, so the problem is probably with some module which gives “SEO & URLs” option in the backoffice –> Preferences.

Full updated code (you can use nginx snippets to have clean configuration):
`server {
server_name proxy.example.com;
return 301 https://proxy.example.com$request_uri;
}

server {
listen 443 ssl http2;
server_name proxy.example.com;

# SSL
ssl_trusted_certificate /etc/letsencrypt/live/proxy.example.com/chain.pem;
ssl_certificate /etc/letsencrypt/live/proxy.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/proxy.example.com/privkey.pem;
include snippets/ssl-config.conf;

# tutaj sie zaczyna calosc proxy dla sklepu
location ^~ /admin9254z9q7u {
    proxy_pass https://presta-czysta-osiem.example.com;
    proxy_ssl_server_name on;
    proxy_ssl_name presta-czysta-osiem.example.com;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Port 443;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection "";

    access_log /var/log/nginx/domains/proxy.example.com.log combined;
    error_log  /var/log/nginx/domains/proxy.example.com.error.log info;
}

location / {
    proxy_pass https://presta-czysta-osiem.example.com;
    proxy_ssl_server_name on;
    proxy_ssl_name presta-czysta-osiem.example.com;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Port 443;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection "";

    access_log /var/log/nginx/domains/proxy.example.com.log combined;
    error_log  /var/log/nginx/domains/proxy.example.com.error.log info;
}

}
`

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.