Jump to content
akaii

Boucle entre le reverse proxy et le serveur web nginx

Recommended Posts

Salut,
Je veux installer Prestashop sur un serveur dédié Nginx appelé « Presta » (192.168.1.19).
Pas l'habitude de nginx et je me demande pourquoi je suis cycle de redirection, aurait besoin de vos conseils.

De mon côté avant Nginx Appelons-le « rproxy » 192.168.1.5 J'ai cette configuration:

server {
    if ($host = www.mydomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen   80;
        server_name     www.mydomain.com;
                return 301 https://www.mydomain.com$request_uri;
}
server {
    listen 443;
    server_name www.mydomain.com;
    error_log /var/log/nginx/mydomain.error.log;
    access_log /var/log/nginx/mydomain.access.log;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/www.mydomain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.mydomain.com/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    set $upstream 192.168.1.19;
    location / {
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass_header Authorization;
        proxy_pass http://$upstream;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 36000s;
        proxy_redirect off;
    }
}

et je reçois sur mon serveur nginx dédié:

server {
        listen   80;
        server_name     www.mydomain.com;

        root /var/www/mydomain;
                index index.php index.html index.htm;

                if ($http_host != "www.mydomain.com") {
                rewrite ^ https://www.mydomain.com$request_uri permanent;
                }
                location = /favicon.ico {
                log_not_found off;
                access_log off;
                }
                location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
                }
                # deny access to .htaccess files, if Apache's document root
                # concurs with nginx's one
                location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
                }
                location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html;
                #try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
                }

                rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
                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;
                rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 last;

                try_files $uri $uri/ /index.php$is_args$args;
                error_page 404 /index.php?controller=404;

                location ~* \.(gif)$ {
                expires 2592000s;
                }
                location ~* \.(jpeg|jpg)$ {
                expires 2592000s;
                }
                location ~* \.(png)$ {
                expires 2592000s;
                }
                location ~* \.(css)$ {
                expires 604800s;
                }
                location ~* \.(js|jsonp)$ {
                expires 604800s;
                }
                location ~* \.(js)$ {
                expires 604800s;
                }
                location ~* \.(ico)$ {
                expires 31536000s;
                }

                # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
                #
                location ~ \.php$ {
                        include snippets/fastcgi-php.conf;
                #fastcgi_pass 127.0.0.1:9000;
                #fastcgi_index  index.php;
                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
                }
}

J'ai toujours eu l'erreur suivante:

2019/12/22 15:44:56 [error] 3031#3031: *9 open() "/var/www/mydomain/img/app_icon.png" failed (2: No such file or directory), client: 192.168.1.5, server: www.mydomain.com, request: "GET /img/app_icon.png HTTP/1.1", host: "www.mydomain.com" 2019/12/22 15:45:03 [error] 3031#3031: *82 open() "/var/www/mydomain/img/app_icon.png" failed (2: No such file or directory), client: 192.168.1.5, server: www.mydomain.com, request: "GET /img/app_icon.png HTTP/1.1", host: "www.mydomain.com"

Quelqu'un a une configuration similaire et pourrait m'aider?

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More