nginx: [emerg] неизвестная переменная "fastcgi_https" - PullRequest
0 голосов
/ 24 сентября 2019

Я запускаю приложение Drupal в Docker (https://github.com/wodby/docker4drupal) с NGINX, PHP-FPM. Оно работает нормально HTTP, но с тех пор, когда я пытаюсь включить HTTPS с самозаверяющим сертификатом, оно выдает эту ошибку ине запускается -

nginx: [emerg] неизвестная переменная "fastcgi_https"

Мой пользовательский файл .conf -

include upstream.conf;
server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
    server_name  SERVERNAME;
    server_tokens on;
    root /var/www/html;
    index index.php;
    include fastcgi.conf;
    add_header  X-XSS-Protection '1; mode=block';
    ssl_certificate /certs/cert.pem;
    ssl_certificate_key /certs/key.pem;
      location /.well-known/acme-challenge/ {
        allow all;
        root /var/www/certbot;
    }
    location / {
        proxy_pass  http://php:9000;
        proxy_redirect  off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header Host $host;
        location ~* /system/files/ {
            include fastcgi.conf;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param SCRIPT_NAME /index.php;
            fastcgi_param SCRIPT_FILENAME $document_root/index.php;
            fastcgi_pass unix:/run/php/php7.2-fpm.sock;
            log_not_found off;
            include fastcgi_params;
        }
        location ~* /sites/.+/files/private/ {
            internal;
        }
        location ~* /files/styles/ {
            access_log off;
            expires 7d;
            try_files $uri @drupal;
        }
        location ~* /sites/.+/files/.+\.txt {
            access_log off;
            expires 7d;
            tcp_nodelay off;
            open_file_cache max=1000 inactive=30s;
            open_file_cache_valid 30s;
            open_file_cache_min_uses 2;
            open_file_cache_errors off;
        }
        location ~* /sites/.+/files/advagg_css/ {
            expires max;
            add_header ETag '';
            add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT';
            add_header Accept-Ranges '';
            location ~* /sites/.*/files/advagg_css/css[_[:alnum:]]+\.css$ {
                access_log off;
                try_files $uri @drupal;
            }
        }
        location ~* /sites/.+/files/advagg_js/ {
            expires max;
            add_header ETag '';
            add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT';
            add_header Accept-Ranges '';
            location ~* /sites/.*/files/advagg_js/js[_[:alnum:]]+\.js$ {
                access_log off;
                try_files $uri @drupal;
            }
        }
        location ~* /admin/reports/hacked/.+/diff/ {
            try_files $uri @drupal;
        }
        location ~* /rss.xml {
            try_files $uri @drupal-no-args;
        }
        location ~* /sitemap.xml {
            try_files $uri @drupal;
        }
        location ~* ^(?:.+\.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|pot|sh|.*sql|test|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
            return 404;
        }
        try_files $uri @drupal;
    }

    location @drupal {
        include fastcgi.conf;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        track_uploads uploads 60s;
        include fastcgi_params;
    }
    location @drupal-no-args {
        include fastcgi.conf;
        fastcgi_param QUERY_STRING q=$uri;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        include fastcgi_params;
    }
    location = /index.php {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
    location = /core/install.php {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
    location ~* ^/core/authorize.php {
        include fastcgi.conf;
        fastcgi_param QUERY_STRING $args;
        fastcgi_param SCRIPT_NAME /core/authorize.php;
        fastcgi_param SCRIPT_FILENAME $document_root/core/authorize.php;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        include fastcgi_params;
    }
    location = /core/modules/statistics/statistics.php {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
    location = /cron {
        include fastcgi.conf;
        fastcgi_param QUERY_STRING $args;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        include fastcgi_params;
    }
    location ~* ^/update.php {
        include fastcgi.conf;
        fastcgi_param QUERY_STRING $args;
        fastcgi_param SCRIPT_NAME /update.php;
        fastcgi_param SCRIPT_FILENAME $document_root/update.php;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        include fastcgi_params;
    }
    location ^~ /patches {
        return 404;
    }
    location ^~ /backup {
        return 404;
    }
    location ~* ^.+\.php$ {
        return 404;
    }
    location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\d*) {
        rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id;
    }
    location ~ ^/progress$ {
        upload_progress_json_output;
        report_uploads uploads;
    }
    location = /libraries/nanospell/server/ajax/php/tinyspell.php {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
    location = /libraries/nanospell/server/ajax/php/spellcheck.php {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
    include defaults.conf;
}

server {
    listen  80;
    listen [::]:80;
  server_name SERVERNAME;
  server_tokens off;

  if ($http_x_forwarded_proto = "http") {
    return 301 https://$server_name$request_uri;
  }
}

Одно решение Я нашел, чтобы добавить это

map $scheme $fastcgi_https {
    default off;
    https on;
}

в nginx.conf, который я не смог добавить, так как контейнер не запускается сейчас. Любая помощь будет оценена :)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...