Skip to content

Provide absolute URL to fix routing issues#61

Merged
Quetzacoalt91 merged 3 commits intoPrestaShop:devfrom
Hlavtox:provide-absolute-url
Oct 30, 2025
Merged

Provide absolute URL to fix routing issues#61
Quetzacoalt91 merged 3 commits intoPrestaShop:devfrom
Hlavtox:provide-absolute-url

Conversation

@Hlavtox
Copy link
Contributor

@Hlavtox Hlavtox commented Jul 25, 2025

Questions Answers
Description? Provide absolute URL to fix routing issues. Fixes potential issues coming from relative URLs not being reliable after symfony migration. See PrestaShop/PrestaShop#39185. cc @Touxten
Type? refactor
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#39185
Sponsor company TRENDO s.r.o.
How to test? Just test the module can be configured correctly and loads in the backoffice, so we didn't break anything or have some typo. (On nginx server, this could be problematic.)

Copy link

@SiraDIOP SiraDIOP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qa by dev

@Hlavtox
Copy link
Contributor Author

Hlavtox commented Sep 20, 2025

@PrestaShop/qa-functional This can be tested normally, doesnt need developer time to test if configuration form works.

@Hlavtox
Copy link
Contributor Author

Hlavtox commented Oct 8, 2025

Ping @PrestaShop/qa-functional @PrestaShop/committers for QA, this is required for this module to work on 9.0.x branch on NGINX.

@Quetzacoalt91
Copy link
Member

Quetzacoalt91 commented Oct 29, 2025

Hi there,

I've deployed a shop on PrestaShop 9.1 with PHP-FPM and Nginx based on this configuration, @SiraDIOP it may help you for the next tests:

Files to use to deploy PrestaShop with Nginx

docker-compose.yml

services:
    mysql:
        image: mariadb:10.3.39
        ports:
            - "3306"
        volumes:
            - dbdata:/var/lib/mysql
            - ./config-files/mysql/conf.d/:/etc/mysql/conf.d
        environment:
            MYSQL_ROOT_PASSWORD: MyEpicPassword
            MYSQL_DATABASE: psreference
    php:
        image: prestashop/prestashop:9-fpm
        expose:
            - "9000"
        depends_on:
            - mysql
        environment:
            DB_SERVER: mysql
            DB_PASSWD: MyEpicPassword
            DB_NAME: psreference
            PS_DOMAIN: localhost:8002
            PS_INSTALL_AUTO: 1
            PS_ERASE_DB: 1
            PS_INSTALL_DB: 1
            PS_FOLDER_ADMIN: admin-dev
            PS_FOLDER_INSTALL: install-dev
            PS_DEV_MODE: 1
            DB_PREFIX: ks_
#            PS_LANGUAGE: fr
#            PS_COUNTRY: FR
        volumes:
            - temp-ps:/var/www/html
    nginx:
        image: nginx
        ports:
            - "8002:80"
            - "443"
        depends_on:
            - php
        volumes:
            - temp-ps:/var/www/html
            - ./config-files/nginx/conf.d/:/etc/nginx/conf.d

volumes:
    dbdata:
    temp-ps:

config-files/nginx/conf.d/:/etc/nginx/conf.d

# -------------------------------------------------------------------------------------------------
# The following file is provided as-is by PrestaShop as an example configuration for your Nginx server.
# It may be incomplete, and remember you must adapt it for your own server's needs!
# Based on the work of MattLoyeD and Michael Dekker.
# -------------------------------------------------------------------------------------------------

server {
    # Ipv4
    listen 80;

    # IPv6
    # listen [::]:80;

    # SSL Ipv4 & v6
    # listen 443 ssl;
    # listen [::]:443 ssl;

    # Your SSL Certificates, don't forget to take a look at Certbot (https://certbot.eff.org)
    # ssl_certificate /etc/ssl/fullchain.pem;
    # ssl_certificate_key /etc/ssl/privkey.pem;

    # ssl_session_timeout 24h;
    # ssl_session_cache shared:SSL:10m;
    # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    # ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:RSA+3DES:AES128-SHA:!ADH:!AECDH:!MD5;
    # ssl_prefer_server_ciphers on;
    # Do not forget to create this file before with OpenSSL : "openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048"
    # ssl_dhparam /etc/nginx/ssl/dhparam.pem;

    root /var/www/html;

    index index.php

    # Redirect 404 errors to prestashop
    error_page 404 /index.php?controller=404;

    # Gzip Settings, convert all types.
    gzip on;
    gzip_vary on;
    gzip_proxied any;

    # Can be enhance to 5, but it can slow you server
    # gzip_comp_level    5;
    # gzip_min_length    256;

    gzip_types
        application/atom+xml
        application/javascript
        application/json
        application/ld+json
        application/manifest+json
        application/rss+xml
        application/vnd.geo+json
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-web-app-manifest+json
        application/xhtml+xml
        application/xml
        font/opentype
        image/bmp
        image/svg+xml
        image/x-icon
        text/cache-manifest
        text/css
        text/plain
        text/vcard
        text/vnd.rim.location.xloc
        text/vtt
        text/x-component
        text/x-cross-domain-policy;

    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    # HSTS (Force clients to interact with your website using HTTPS only)
    # For enhanced security, register your site here: https://hstspreload.org/
    # WARNING: Don't use this if your site is not fully on HTTPS!
    # add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" preload; always;

    # Cloudflare / Max CDN fix
    location ~* \.(eot|otf|ttf|woff|woff2)$ {
        add_header Access-Control-Allow-Origin *;
    }

    # Do not save logs for these
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location = /robots.txt {
        auth_basic off;
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        # Redirect pretty urls to index.php
        try_files $uri $uri/ /index.php?$args;

        # Images
        rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
        rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
        rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
        rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
        rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;

        # AlphaImageLoader for IE and fancybox
        rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;

        # Web service API
        rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

        # Installation sandbox
        rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
    }

    location /admin-dev/ {
        try_files $uri $uri/ /admin-dev/index.php$is_args$args;
    }

    # File security
    # .htaccess .DS_Store .htpasswd etc
    location ~ /\. {
        deny all;
    }
    # Source code directories
    location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor)/ {
        deny all;
    }
    # Prevent exposing other sensitive files
    location ~ \.(yml|log|tpl|twig|sass)$ {
        deny all;
    }

    # Prevent injection of php files
    location /upload {
        location ~ \.php$ {
            deny all;
        }
    }
    location /img {
        location ~ \.php$ {
            deny all;
        }
    }

    # PHP FPM part
    location ~ [^/]\.php(/|$) {
        # Verify that the file exists, redirect to index if not
        try_files $fastcgi_script_name /index.php$uri&$args;

        fastcgi_index  index.php;

        # Envirnoment variables for PHP
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        include       fastcgi_params;

        fastcgi_param PATH_INFO       $fastcgi_path_info;
        #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        # [REQUIRED EDIT] Connection to PHP-FPM - choose one
        # fastcgi_pass 127.0.0.1:9000;
        # fastcgi_pass unix:/run/php/php7.0-fpm.sock;
	fastcgi_pass php:9000;

        fastcgi_keep_conn on;
        fastcgi_read_timeout 30s;
        fastcgi_send_timeout 30s;

        # In case of long loading or 502 / 504 errors
        # fastcgi_buffer_size 256k;
        # fastcgi_buffers 256 16k;
        # fastcgi_busy_buffers_size 256k;
        client_max_body_size 10M;
    }
}

Results

Current behavior (master branch)

Capture.video.du.2025-10-29.11-34-40.mp4

This pull-request

Capture.video.du.2025-10-29.11-32-44.mp4

There is an issue while trying to reach the order. With the new URL, you reach the list of orders while we expect to reach a specific order.
Can you check this @Hlavtox? 🙏

@Hlavtox
Copy link
Contributor Author

Hlavtox commented Oct 29, 2025

@Quetzacoalt91 Should be good now!

@SiraDIOP SiraDIOP self-assigned this Oct 30, 2025
@Quetzacoalt91 Quetzacoalt91 removed this from the 2.1.5 milestone Oct 30, 2025
@Quetzacoalt91 Quetzacoalt91 added this to the 2.2.0 milestone Oct 30, 2025
@SiraDIOP
Copy link

Hello @Hlavtox,

Thanks for your PR,

I tested it and i follow the how to test with nginx and it's good for me

Thanks

@Quetzacoalt91 Quetzacoalt91 merged commit a2175cf into PrestaShop:dev Oct 30, 2025
8 of 9 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Merged in PR Dashboard Oct 30, 2025
@ps-jarvis ps-jarvis moved this from Merged to Ready for review in PR Dashboard Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Corrupted module URLs after symfony layout migration of configuration page

10 participants