Zemmouri Tarek
Zemmouri Tarek

Reputation: 118

Prestashop container can't display css and js on front page

So i'am working with a containerazed Prestashop running with a db and phpmyadmin, in a docker-compose file. Everything works fine in the back of the shop but the front, the css and js isn't loaded at all... i really don't understand the problem. Hope some people might help. I have configured the web server with nginx on a reverse proxy for the container. I'am using bitnami prestashop image. I don't know what's the problem, is it my nginx conf ? Bitnami image ?

Hope somone can help me.

server {
        ######################
        # REGULAR PARAMETERS #
        ######################

        server_name exemple.com www.exemple.com
        root installation_prestashop_file

        index index.php;

#        listen [::]:443 ssl ipv6only=on http2;
        listen 443 ssl http2;

        # Comment this if you are not using Certbot
        ssl_certificate /etc/letsencrypt/live/exemple.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/exemple.com/privkey.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf; 
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 

        error_log /var/log/nginx/exemple.com.error;


        ########################
        # LOCATION DIRECTIVES #
        ########################

        # PHP Status monitor, uncomment if needed (you have to enable it in your PHP-FPM pool config)
        # location ~ ^/(status|ping)$ {
        #        allow 127.0.0.1;
        #        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #        fastcgi_index index.php;
        #        include fastcgi_params;
        #        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        # }

        # Change this to your default admin path (for ex. /admin-mywebsite ; prefix the URL with a "/")
        set $admin_dir /exemple;

        # Symfony controllers
       # location ~ /(international|sell|improve|_profiler|module|product|feature|attribute|supplier|combination|specific-price|configure)/(.*)$ {
        #        try_files $uri $uri/ /index.php?q=$uri&$args $admin_dir/index.php$is_args$args;
        #}

        # Default locations
        location / {
    include  /etc/nginx/mime.types;
        proxy_pass http://127.0.0.1:8080;
    #proxy_redirect     off;
        proxy_set_header   Host $host;  
        }

        # Use only one of the following php location according to your PHP configuration
        #location ~ [^/]\.php(/|$) {
                # Verify that the file exists, redirect to index if not 
                #try_files $fastcgi_script_name /index.php$uri&$args =404;
                #fastcgi_index index.php;

                # Environment 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;

                # Optimized for CloudFlare CDN, if you are not using it you can increase theses variables according to your needs
               # fastcgi_keep_conn on;
               # fastcgi_read_timeout 100s;
                #fastcgi_send_timeout 100s;
                #client_max_body_size 20M;
                #fastcgi_max_temp_file_size 0;
                #fastcgi_temp_file_write_size 512k;

                # Change this for your PHP socket
                #fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        #}

        # If the PHP directive from the top didn't work, use the following one:
        #    location ~ \.php$ {
        #       try_files $uri =404;
        #       fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        #       fastcgi_index index.php;
        #       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #       include fastcgi_params;
        #    }

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

#        location ~* ^.+\.(css|js|ogg|ogv|svg|svgz|eot|otf|woff|woff2|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
#                access_log off;
#                log_not_found off;
#                expires max;
#                add_header Pragma public;
#                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
#        }

#        location ~* \.(pdf)$ {
#                expires 30d;
#        }

#        location = /favicon.ico {
#                log_not_found off;
#                access_log off;
#        }

#        location = /robots.txt {
#                allow all;
#                log_not_found off;
#                access_log off;
#        }

        # 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|var)/ {
#            deny all;
#        }

#        location ~ \.(htaccess|yml|log|twig|sass|git|tpl)$ {
#                deny all;
#        }

        # vendor in modules directory
#        location ~ ^/modules/.*/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;
#            }
#        }


#edit by elise
#location ~* \.(eot|ttf|woff|woff2)$ {
#    add_header Access-Control-Allow-Origin *;
#}

        ######################
        # REWRITE DIRECTIVES #
        ######################

        # Uncomment & edit this if you are using multilanguage (preset for french here)
        # rewrite ^/fr$ /fr/ redirect;
        # rewrite ^/fr/(.*) /$1;

        # Rewrite for admin directory
#        location $admin_dir/ {
#            if (!-e $request_filename) {
#                rewrite ^/.*$ $admin_dir/index.php last;
#            }
#        }

        # 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;

        # Products and regular pages
#        rewrite "^/([0-9]+)\-(\P{M}\p{M}*)+\.html(.*)$" /index.php?controller=product&id_product=$1$3 last;
#        rewrite "^/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=category&id_category=$1$3 last;
#        rewrite "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /index.php?controller=product&id_product=$2$4 last;
#        rewrite "^/([0-9]+)__([a-zA-Z0-9-]*)(.*)$" /index.php?controller=supplier&id_supplier=$1$3 last;
#        rewrite "^/([0-9]+)_([a-zA-Z0-9-]*)(.*)$" /index.php?controller=manufacturer&id_manufacturer=$1$3 last;
#        rewrite "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms=$1$3 last;
#        rewrite "^/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms_category=$1$3 last;
#        rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

        # EN rewrites
#        rewrite ^/address$ /index.php?controller=address last;
#        rewrite ^/addresses$ /index.php?controller=addresses last;
#        rewrite ^/authentication$ /index.php?controller=authentication last;
#        rewrite ^/best-sales$ /index.php?controller=best-sales last;
#        rewrite ^/brand$ /index.php?controller=manufacturer last;
#        rewrite ^/brand/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /index.php?id_manufacturer=$1&controller=manufacturer;
#        rewrite ^/cart$ /index.php?controller=cart last;
#        rewrite ^/contact-us$ /index.php?controller=contact-form last;
#        rewrite ^/discount$ /index.php?controller=discount last;
#        rewrite ^/guest-tracking$ /index.php?controller=guest-tracking last;
#        rewrite ^/identity$ /index.php?controller=identity last;
#        rewrite ^/manufacturers$ /index.php?controller=manufacturer last;
#        rewrite ^/my-account$ /index.php?controller=my-account last;
#        rewrite ^/new-products$ /index.php?controller=new-products last;
#        rewrite ^/new-products$ /index.php?controller=new-products last;
#        rewrite ^/order$ /index.php?controller=order last;
#        rewrite ^/order-follow$ /index.php?controller=order-follow last;
#        rewrite ^/order-follow$ /index.php?controller=order-follow last;
#        rewrite ^/order-history$ /index.php?controller=history last;
#        rewrite ^/order-slip$ /index.php?controller=order-slip last;
#        rewrite ^/page-not-found$ /index.php?controller=404 last;
#        rewrite ^/password-recovery$ /index.php?controller=password last;
#        rewrite ^/quick-order$ /index.php?controller=order-opc last;
#        rewrite ^/search$ /index.php?controller=search last;
#        rewrite ^/stores$ /index.php?controller=stores last;
#        rewrite ^/supplier$ /index.php?controller=supplier last;

        # FR rewrites
#        rewrite ^/adresse$ /index.php?controller=address last;
#        rewrite ^/adresses$ /index.php?controller=addresses last;
#        rewrite ^/avoirs$ /index.php?controller=order-slip last;
#        rewrite ^/commande$ /index.php?controller=order last;
#        rewrite ^/commande-rapide$ /index.php?controller=order-opc last;
#        rewrite ^/comparaison-produits$ /index.php?controller=products-compare last;
#        rewrite ^/confirmation-commande$ /index.php?controller=order-confirmation last;
#        rewrite ^/connexion$ /index.php?controller=authentication last;
#        rewrite ^/fabricants$ /index.php?controller=manufacturer last;
#        rewrite ^/fournisseur$ /index.php?controller=supplier last;
#        rewrite ^/fournisseurs$ /index.php?controller=supplier last;
#        rewrite ^/historique-commandes$ /index.php?controller=history last;
#        rewrite ^/identite$ /index.php?controller=identity last;
#        rewrite ^/magasins$ /index.php?controller=stores last;
#        rewrite ^/meilleures-ventes$ /index.php?controller=best-sales last;
#        rewrite ^/mon-compte$ /index.php?controller=my-account last;
#        rewrite ^/nous-contacter$ /index.php?controller=contact-form last;
#        rewrite ^/nouveaux-produits$ /index.php?controller=new-products last;
#        rewrite ^/page-introuvable$ /index.php?controller=404 last;
#        rewrite ^/panier$ /index.php?controller=cart last;
#        rewrite ^/plan-site$ /index.php?controller=sitemap last;
#        rewrite ^/promotion$ /index.php?controller=discount last;
#        rewrite ^/promotions$ /index.php?controller=prices-drop last;
#        rewrite ^/recherche$ /index.php?controller=search last;
#        rewrite ^/recuperation-mot-de-passe$ /index.php?controller=password last;
#        rewrite ^/reduction$ /index.php?controller=discount last;
#        rewrite ^/sitemap$ /index.php?controller=sitemap last;
#        rewrite ^/suivi-commande$ /index.php?controller=order-follow last;
#        rewrite ^/suivi-commande-invite$ /index.php?controller=guest-tracking last;
}


#################
# HTTP REDIRECT #
#################

#server {
#    server_name sales.bioservice.tech;

#    if ($host = sales.bioservice.tech) {
#        return 301 https://$host$request_uri;
#    }
    
#    listen 80;
#    listen [::]:80;

#    return 404;

Upvotes: 1

Views: 359

Answers (1)

KoreLewi
KoreLewi

Reputation: 447

Try with this docker compose file, it's working fine for me.

  1. Create a docker-compose.yml file
  2. Copy the code to the file
  3. Run "docker-compose up"

version: '3.9'

services:
  mysql:
    image: mysql:8
    container_name: prestashop-db
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_DATABASE: prest
      MYSQL_ROOT_PASSWORD: presta
    ports:
      - 3306:3306
    networks:
      - prestashop

  prestashop:
    image: prestashop/prestashop:1.7
    container_name: prestashop
    command: --PS_DEV_MODE=true
    environment:
      DB_SERVER: mysql
    ports:
      - 8080:80
    networks:
      - prestashop

networks:
  prestashop:

Upvotes: 1

Related Questions