【问题标题】:Nginx Magento SSL ERR_TOO_MANY_REDIRECTSNginx Magento SSL ERR_TOO_MANY_REDIRECTS
【发布时间】:2016-03-04 20:52:36
【问题描述】:

我有一个错误 ERR_TOO_MANY_REDIRECTS

我实现了 ssl,但我得到了错误

在 Magento 中,我有使用 ssl 的网站

web/unsecure/base_url https://pontebuso.com/

web/secure/base_url https://pontebuso.com/

------------------nginx.conf--------------

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
sendfile on;
autoindex off;


tcp_nopush on;
tcp_nodelay on;

types_hash_max_size 2048;

fastcgi_param HTTPS on;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

#include /etc/nginx/mime.types;
default_type application/octet-stream;


access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip  on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

include       /etc/nginx/mime.types;
include       /etc/nginx/conf.d/*.conf;
include       /etc/nginx/sites-enabled/default;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request "'
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

map $scheme $fastcgi_https { ## Detect when HTTPS is used
    default off;
    https on;
}

------------------站点------------------

server {
    listen 80;
    server_name pontebuso.com;
    rewrite ^/(.*) https://pontebuso.com/$1 permanent;
}

server {
    listen 443 ssl;

    server_name pontebuso.com;

    ssl on;
    ssl_certificate /etc/nginx/ssl/pontebuso.com.chained.crt;
    ssl_certificate_key /etc/nginx/ssl/pontebuso.key;   

    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_prefer_server_ciphers on;



    add_header Access-Control-Allow-Origin sub.pontebuso.com;
    root /home/sites/pontebuso/;

    autoindex off;

    access_log /var/log/nginx/nginx.vhost.access.log;
    error_log /var/log/nginx/nginx.vhost.error.log;

    location / {
        proxy_set_header        X-Forwarded-Proto $scheme;
        fastcgi_param HTTPS on;
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args; 
        access_log off;
        #expires max; 
    }


    ## These locations would be hidden by .htaccess normally
    location ^~ /app/                { deny all; }
    location ^~ /includes/           { deny all; }
    location ^~ /lib/                { deny all; }
    location ^~ /media/downloadable/ { deny all; }
    location ^~ /pkginfo/            { deny all; }
    location ^~ /report/config.xml   { deny all; }
    location ^~ /var/                { deny all; }


    location /var/export/ {
        auth_basic           "Restricted";
        auth_basic_user_file htpasswd;
        autoindex            on;
    }

    location  /. {
        return 404;
    }

    location @handler {
        rewrite / /index.php;
    }

    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }

    location ~ .php$ {
        if (!-e $request_filename) { rewrite / /index.php last; }
        expires        off;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  MAGE_RUN_CODE default;
        fastcgi_param  MAGE_RUN_TYPE store;
        include        fastcgi_params;
    }

    location ~ \.css {
        add_header  Content-Type    text/css;
    }

    location ~ \.js {
        add_header  Content-Type    application/x-javascript;
    }
  }

------------------------默认--------

server {
    listen 80;

    server_name pontebuso.com;
    add_header Access-Control-Allow-Origin sub.pontebuso.com;
    root /home/sites/pontebuso/;

    autoindex off;

    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args; 
        access_log off;
        expires max; 
    }

    ## These locations would be hidden by .htaccess normally
    location ^~ /app/                { deny all; }
    location ^~ /includes/           { deny all; }
    location ^~ /lib/                { deny all; }
    location ^~ /media/downloadable/ { deny all; }
    location ^~ /pkginfo/            { deny all; }
    location ^~ /report/config.xml   { deny all; }
    location ^~ /var/                { deny all; }

    access_log /var/log/nginx/nginx.vhost.access.log;
    error_log /var/log/nginx/nginx.vhost.error.log;

    location /var/export/ {
        auth_basic           "Restricted";
        auth_basic_user_file htpasswd;
        autoindex            on;
    }

    location  /. {
        return 404;
    }

    location @handler {
        rewrite / /index.php;
    }

    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }

    location ~ .php$ {
        if (!-e $request_filename) { rewrite / /index.php last; }
        expires        off;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  MAGE_RUN_CODE default;
        fastcgi_param  MAGE_RUN_TYPE store;
        include        fastcgi_params;
    }

    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
     }


     location ~ .php$ { 
        if (!-e $request_filename) { rewrite / /index.php last; }
        expires        off; ## Do not cache dynamic content
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  MAGE_RUN_CODE default;
        fastcgi_param  MAGE_RUN_TYPE store;
        include        fastcgi_params; ## See /etc/nginx/fastcgi_params
    }

    location ~ \.css {
        add_header  Content-Type    text/css;
    }

    location ~ \.js {
        add_header  Content-Type    application/x-javascript;
    }


}

【问题讨论】:

    标签: magento ssl nginx


    【解决方案1】:

    正如我所见,css 没有通过 https 正确加载。因此,请仅使用带有基本安全 URL 的 https。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-17
      • 2018-03-06
      • 2017-10-04
      • 1970-01-01
      • 1970-01-01
      • 2019-07-23
      • 2019-09-05
      • 1970-01-01
      相关资源
      最近更新 更多