Jump to content

nginx


Rashp
 Share

Go to solution Solved by 100napb,

Recommended Posts

Всем здравствуйте!

Подскажите пожалуйста, как правильно закрыть IP в nginx от прямого доступа? Надоели левые запросы по IP и не повлияет ли это на индексацию?

Я сделал следующую конструкцию, не знаю, корректно ли это?

server {
    listen 80;
    server_name domain.ru www.domain.ru;
    return 301 https://domain.ru$request_uri;

}

server {
    set $host_path "/var/www/webroot";
    set $index "index.php";
    set $fpm_sock "/run/php/php7.3-fpm-domain.sock";

    listen 443 ssl http2;
    ssl_certificate /etc/nginx/ssl/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/privkey.pem;
    ssl_trusted_certificate /etc/nginx/ssl/chain.pem;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Permitted-Cross-Domain-Policies master-only;
    add_header X-Content-Type-Options nosniff;

    set $domain_name "domain.ru";
    server_name domain.ru www.domain.ru;
    root        $host_path/;
    index       $index;


    default_type text/html;
    access_log off;
    error_log   /var/www/logs/nginx/error.log crit;

    if ($host = 'www.$domain_name') {

    return 301 https://$domain_name$request_uri;
    }

server {
listen 0.0.0.0:80 default_server;
listen 0.0.0.0:443 default_server;
server_name _;
return 444;
 }

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...