A
A
AnonDanon2020-06-09 11:49:27
Nginx
AnonDanon, 2020-06-09 11:49:27

What am I doing wrong with nginx + cloudflare ssl setup?

In general, I decided to roll a certificate from Cloudflare onto the site so that for 15 years and not suffer with updates. Before that, there was Let'sencrypt. I installed everything on the server, started it - it works on default. But as soon as I tried to edit this file to work with the Cloudflare certificate, nothing came of it. I would be grateful for the help, somewhere I just need to change a couple of lines, but I can’t understand where, I tried a lot of options, but all to no avail

. This is the original from which I dance:

server {

  listen 80;
  server_name mydomain.com www.mydomain.com;
  root /var/www/vanilla;
  index index.php;

  location ~* /\.git { deny all; return 403; }
  location /build/ { deny all; return 403; }
  location /cache/ { deny all; return 403; }
  location /cgi-bin/ { deny all; return 403; }
  location /uploads/import/ { deny all; return 403; }
  location /conf/ { deny all; return 403; }
  location /tests/ { deny all; return 403; }
  location /vendor/ { deny all; return 403; }

  location ~* ^/index\.php(/|$) {
    include snippets/fastcgi-php.conf;
    fastcgi_param SCRIPT_NAME /index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
    fastcgi_param X_REWRITE 1;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  }

  location ~* \.php(/|$) {
    rewrite ^ /index.php$uri last;
  }

  location / {
    try_files $uri $uri/ @vanilla;
  }

  location @vanilla {
    rewrite ^ /index.php$uri last;
  }

}


This is what I danced already, one of the options. Does not work :/

server {

  listen 80;
  listen [::]:80;
  server_name mydomain.com www.mydomain.com;

  return 302 https://$server_name$request_uri;

  location ~* /\.git { deny all; return 403; }
  location /build/ { deny all; return 403; }
  location /cache/ { deny all; return 403; }
  location /cgi-bin/ { deny all; return 403; }
  location /uploads/import/ { deny all; return 403; }
  location /conf/ { deny all; return 403; }
  location /tests/ { deny all; return 403; }
  location /vendor/ { deny all; return 403; }

  location ~* ^/index\.php(/|$) {
    include snippets/fastcgi-php.conf;
    fastcgi_param SCRIPT_NAME /index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
    fastcgi_param X_REWRITE 1;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  }

  location ~* \.php(/|$) {
    rewrite ^ /index.php$uri last;
  }

  location / {
    try_files $uri $uri/ @vanilla;
  }

  location @vanilla {
    rewrite ^ /index.php$uri last;
  }

}

server {

# SSL configuration

listen 443 ssl http2;

listen [::]:443 ssl http2;

ssl        on;

ssl_certificate         /etc/ssl/certs/cert.pem;

ssl_certificate_key     /etc/ssl/private/key.pem;
server_name mydomain.com www.mydomain.com;
root /var/www/vanilla;
index index.php
}


https://justpaste.it/7a9e2 - /var/log/nginx/error.log

Many thanks to dodo512!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Barbolin, 2020-06-09
@dronmaxman

Department of telepathy, hello!!!
Can you even see the error? What exactly doesn't work?

A
AnonDanon, 2020-06-09
@AnonDanon

The problem is definitely not in CF, because according to this instruction, I have already created 10 static sites and everything was ok. But the forum does not work.

A
Andrey Gavrilov, 2020-06-10
@thexaver

Make one server with port 443 and cloud certificate, and configure everything on it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question