A
A
Anton2019-05-14 00:23:30
Nginx
Anton, 2019-05-14 00:23:30

How to make an exception for the url so that it is available not via https, but via http?

Site on https and without www on nginx
How to url

/bitrix/admin/1c_exchange.php

to make access on http (without ssl)?
spoiler
server {
  server_name www.test.ru;
  return 301 https://test.ru$request_uri;
  ssl on;
  ssl_certificate "/var/www/httpd-cert/www-root/Tests.crtca";
  ssl_certificate_key "/var/www/httpd-cert/www-root/Tests.key";
  ssl_ciphers EECВЫРЕЗАНОRC4;
  ssl_prefer_server_ciphers on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  add_header Strict-Transport-Security "max-age=31536000;";
  ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
  charset UTF-8;
  index index.php;
  disable_symlinks if_not_owner from=$root_path;
  include /etc/nginx/vhosts-includes/*.conf;
  include /etc/nginx/vhosts-resources/test.ru/*.conf;
  access_log /var/www/httpd-logs/test.ru.access.log;
  error_log /var/www/httpd-logs/test.ru.error.log notice;
  ssi on;
  set $root_path /var/www/www-root/data/www/test.ru;
  root $root_path;
  listen ВЫРЕЗАНО:443;
      if (!-e $request_filename) {
      rewrite  ^(.*)$  /bitrix/urlrewrite.php last;
   }
  gzip on;
  gzip_comp_level 5;
  gzip_disable "msie6";
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
  expires 2m;
  location / {
    location ~ [^/]\.ph(p\d*|tml)$ {
      try_files /does_not_exists @php;
    }
  }
  location @php {
    fastcgi_index index.php;
    fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
    fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
    fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    try_files $uri =404;
    include fastcgi_params;
  }
}
server {
  server_name test.ru;
  ssl on;
  ssl_certificate "/var/www/httpd-cert/www-root/Tests.crtca";
  ssl_certificate_key "/var/www/httpd-cert/www-root/Tests.key";
  ssl_ciphers EECDВЫРЕЗАНОRC4;
  ssl_prefer_server_ciphers on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  add_header Strict-Transport-Security "max-age=31536000;";
  ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
  charset UTF-8;
  index index.php;
  disable_symlinks if_not_owner from=$root_path;
  include /etc/nginx/vhosts-includes/*.conf;
  include /etc/nginx/vhosts-resources/test.ru/*.conf;
  access_log /var/www/httpd-logs/test.ru.access.log;
  error_log /var/www/httpd-logs/test.ru.error.log notice;
  ssi on;
  set $root_path /var/www/www-root/data/www/test.ru;
  root $root_path;
  listen ВЫРЕЗАНО:443;
      if (!-e $request_filename) {
      rewrite  ^(.*)$  /bitrix/urlrewrite.php last;
   }
  gzip on;
  gzip_comp_level 5;
  gzip_disable "msie6";
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    expires 2m;
  location / {
    location ~ [^/]\.ph(p\d*|tml)$ {
      try_files /does_not_exists @php;
    }
  }
  location @php {
    fastcgi_index index.php;
    fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
    fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
    fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    try_files $uri =404;
    include fastcgi_params;
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-05-14
@anton99zel

RewriteCond %{HTTPS} off
   # Проверяем наличие https в URL.
RewriteCond %{REQUEST_URI} !/bitrix/admin/1c_exchange.php/$
# ! - отрицание 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
   # Перенаправляем протокол на http.

Actually replace your redirect with https and the whole page will be available,
don’t forget that the browser itself caches https requests and likes to cling to them, but it doesn’t hurt to exchange with 1s.
check the online server response service to make sure that 200
But it’s better, of course, to upgrade the exchange plan to the new version, there you don’t need these crutches, it easily works on https

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question