S
S
Shurik2020-12-24 04:52:48
Drupal
Shurik, 2020-12-24 04:52:48

How to properly setup nginx virtual host for this url?

Hello. Faced a problem (from my point of view) in the nginx setup. The point is the following.
I am migrating a Drupal 8 site to vds from a regular hosting. The hosting worked fine. When I clear the browser cache from the admin panel in the address bar of the browser with this action, we have

site.ru/admin/flush?token=SCRSNrTlLz3owG6oXxZOw-UXURZC03d8JYsCfWtKWJ0
. After moving, when I try to clear the cache, the site gives an access error (Access denied. You are not authorized to access this page.) while I am authorized on the site.
I guess that the rule for this url is not specified in nginx.conf. Generally confused with these location{}. Below are the server{} settings blocks for this virtual host.
And yet, taking this opportunity, the specialists could look at my settings, what can be optimized in them!? For example, is it possible for all virtual hosts to put the same settings in a common block? Well, things like that are interesting. Strongly do not kick, nginx for the first time I put.
server {
  listen *:80;
  server_name site.ru www.site.ru;
  root /var/www/html/site.ru/web;
  index index.php;
  location / {
  try_files $uri $uri/ /index.php?q=$uri$args;
  }
  return 301 https://$host:443$request_uri;
    location ~ \.php$ {
  try_files $uri =404;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 256 16k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
  include fastcgi_params;
  }
  }

  server {
  listen 443 ssl;
  server_name site.ru www.site.ru;
  root /var/www/html/site.ru/web;
  index index.php;
   ssl on;
  ssl_certificate /etc/letsencrypt/live/site.ru/fullchain.pem;
   ssl_certificate_key /etc/letsencrypt/live/site.ru/privkey.pem;
  location / {
  try_files $uri $uri/ /index.php?q=$uri$args;
  }

  location ~ \.php$ {
  try_files $uri =404;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 256 16k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
  include fastcgi_params;
  }
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shurik, 2020-12-24
@svisch

Replaced


location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}

on the

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

Everything worked.
But I'm waiting for criticism and advice on nginx.conf
I would be very grateful !!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question