0

Browsing through my site is working fine, but when I do some modification on my Drupal site, it goes to http instead of https, which gives "Connection timeout".

The Drupal site depend on drupal 9.4.5, nginx as web server, Cloudflare as DNS, Keycloak as SSO.

Nginx site conf:

server {
    server_name example.com www.example.com;
    root /var/www/www.example.com/web;
    listen 80;
    listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/snakeoil.conf;
    client_max_body_size 10M;

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

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

    location ~* \.(txt|log)$ {
        allow 192.168.0.0/16;
        deny all;
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    location ~ ^/sites/[^/]+/files/.*\.php$ {
        deny all;
    }

    location ~* ^/.well-known/ {
        allow all;
    }

    location ~ (^|/)\. {
        return 403;
    }

    location / {
        try_files $uri /index.php?$query_string;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ {
        deny all;
        return 404;
    }

    location ~ '\.php$|^/update.php' {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        try_files $fastcgi_script_name =404;
        include fastcgi_params;
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }

    location ~ ^/sites/.*/files/styles/ {
        try_files $uri @rewrite;
    }

    location ~ ^(/[a-z\-]+)?/system/files/ {
        try_files $uri /index.php?$query_string;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        try_files $uri @rewrite;
        expires max;
        log_not_found off;
    }

    if ($request_uri ~* "^(.*/)index\.php(.*)") {
        return 307 $1$2;
    }
}

Cloudflare DNS records:

;; A Records
example.com.    1   IN  A   SERVER_IP_ADDRESS

;; CNAME Records
www.example.com.    1   IN  CNAME   example.com.

I'm not sure in which component should be this issue.

2
  • 1
    There isn't much to go on here so I will downvote this and ask questions. Is there a forward proxy for the site? Drupal's determination of request HTTPS status depends on trusted proxy headers, or, the $_SERVER['HTTPS'] being 'on'. See api.drupal.org/api/drupal/…
    – cilefen
    Sep 26, 2022 at 19:42
  • @cilefen I've added my nginx conf file and cloudflare dns records masking my domain by example.com, not sure where where to check the incoming requests. Sep 27, 2022 at 21:37

1 Answer 1

1

Set fastcgi_param HTTPS 'on';.

Source: https://ma.ttias.be/setting-https-server-variables-in-php-fpm-with-nginx/

1
  • Thanks @cilefen, I think this fixed the issue. Sep 29, 2022 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.