перенаправить мой веб-сайт на http, а не https (nginx)

На самом деле у моего ssl-сертификата истек срок действия и он не обновляется, поэтому я хочу, чтобы мой веб-сайт перенаправлялся на http вместо https.

Файл Myconfig:

           server {
        listen 80 ;
        listen [::]:80 default_server;

        # SSL configuration
        #
         listen 443 ssl default_server;
         listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
         # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/laravel/public;

        # Add index.php to the list if you are using PHP
        index index.php  index.html index.htm index.nginx-debian.html;

        server_name aksout.com ;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/aksout.com/fullchain.pem;
       ssl_certificate_key /etc/letsencrypt/live/aksout.com/privkey.pem;
          location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }
            location /phpmyadmin {

             alias /var/www/laravel/public/;
              index index.php index.html index.htm;
             }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
           location ~ \.php$ {
                                    include snippets/fastcgi-php.conf;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;

        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;



                include fastcgi_params;



                 fastcgi_buffers 8 512k;
        fastcgi_buffer_size 256k;
        fastcgi_send_timeout 5m;
        fastcgi_read_timeout 5m;
            fastcgi_connect_timeout 5m;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }
              location ~ /.well-known {

                allow all;}


}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.

         server {
       listen 80;
#       listen [::]:80;
#
     server_name aksout.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }

    return 301 http://aksout.com$request_uri;
}
0
задан 22 April 2017 в 06:29
4 ответа

Во-первых, без действующего сертификата SSL вы не можете перенаправить на HTTP. Браузеры пользователей будут показывать предупреждение SSL, и, если они не добавят исключения, они никогда не достигнут вашего сервера по HTTPS.

Однако вы можете обслуживать людей, которые входят по HTTP.

В первом блоке сервера:

  • Закомментируйте строки прослушивания 443
  • Закомментируйте материал сертификата SSL

Затем закомментируйте второй блок сервера, исходный порт 80.

2
ответ дан 5 December 2019 в 08:18

Я только что удалил материал 443 / HTTPS и другой ваш блок, который перенаправляет на него трафик

server {
        listen 80 ;
        listen [::]:80 default_server;
        server_name aksout.com ;
        root /var/www/laravel/public;

        # Add index.php to the list if you are using PHP
        index index.php  index.html index.htm index.nginx-debian.html;

        location / {
          # First attempt to serve request as file, then
          # as directory, then fall back to displaying a 404.
          try_files $uri $uri/ /index.php?$query_string;
        }
        location /phpmyadmin {
          alias /var/www/laravel/public/;
          index index.php index.html index.htm;
        }

        # pass the PHP scripts to FastCGI server listening on socket
        location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass unix:/run/php/php7.0-fpm.sock;
          include fastcgi_params;
          fastcgi_buffers 8 512k;
          fastcgi_buffer_size 256k;
          fastcgi_send_timeout 5m;
          fastcgi_read_timeout 5m;
          fastcgi_connect_timeout 5m;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }

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


}
0
ответ дан 5 December 2019 в 08:18

Вы не должны перенаправлять https на http только потому, что срок действия вашего сертификата истек. Вместо этого вам следует обновить его, тем более что у вас уже есть все необходимое для letsencrypt в вашем файле конфигурации.

Выполнение следующей команды должно снова заставить ваш https работать нормально.

certbot renew

Если он показывает какие-либо ошибки, следуйте этому простому руководству to (пере) установить letsencrypt для nginx на debian .

2
ответ дан 5 December 2019 в 08:18

Попробуйте перенаправить htaccess:

RewriteCond% {SERVER_PORT} 443 RewriteRule ^ /? $ http: //% {SERVER_NAME} / [R = 301, L]

-4
ответ дан 5 December 2019 в 08:18

Теги

Похожие вопросы