How to prevent auto-redirect from http to https?

5

My development web container uses the php: 7.1-apache image. To make it easier to memorize the address of the applications contained in this container, I like to edit the Hosts file on my machine and point it this way:

127.0.0.1   site.dev

However, recently I had difficulties with this approach, it seems that browsers have recently forced HTTPS, that is, I am redirected and consequently I fall into a browser error page since SSL is not configured on the server apache that runs in the container.

Any solution to this, other than setting up SSL?

The host system that runs the container is a Mac OS (last stable release)

Follow the data to mount the container:

docker-compose.yaml

version: "3.3"
services:
  mysql:
    container_name: mysql
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: senha_root
      MYSQL_DATABASE: banco
      MYSQL_USER: root
      MYSQL_PASSWORD: senha_user
    command: ['--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
    volumes:
      - ./mysql/tmp:/var/lib/mysql
    restart: on-failure
    ports:
      - 3306:3306

  web:
    container_name: web
    image: web_dev
    build:
      context: .
      dockerfile: Dockerfile-web
    volumes:
      - ./projetos/:/var/www
      - ./apache/:/etc/apache2/sites-enabled/
    working_dir: /var/www
    depends_on:
      - mysql
    links:
      - mysql
    restart: on-failure #always
    ports:
      - 80:80
      - 3000:3000
      - 3001:3001

Dockerfile

FROM php:7.1-apache

MAINTAINER Fabio J L Ferreira <[email protected]>

RUN apt-get update; \
    a2enmod rewrite; \
    apt-get install -y curl unzip git npm libpng-dev; \
    curl -sL https://deb.nodesource.com/setup_8.x | bash -; \
    apt-get install -y nodejs; \
    echo "America/Sao_Paulo" > /etc/timezone; \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

# Install PHP "gd" extension
# RUN apt-get install -y libjpeg-dev libpng12-dev
# RUN docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd

# Instala a extensão PHP "exif" => http://php.net/manual/pt_BR/intro.exif.php
# RUN apt-get install -y libexif-dev && RUN docker-php-ext-install exif

# Extensão "mysqi" e algumas "PDO" => http://php.net/manual/pt_BR/book.pdo.php
RUN apt-get install -y libpq-dev; \
    docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql; \
    docker-php-ext-install mysqli pdo_mysql pgsql pdo_pgsql

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*

COPY php/php.ini /usr/local/etc/php/
    
asked by anonymous 04.01.2018 / 15:56

2 answers

8

According to the link and the link

Since Chrome 63 (December 2017), it will force all domains ending in .dev (and .foo ) to be redirected to HTTPS preloaded with the HTTP Strict Transport Security (HSTS) header, which will allow use the *.dev domain for development (now I believe it is *.test used).

There is also a proposal to use *.localhost to always point to 127.0.0.1 by default at link

  

Note: The AP has confirmed that the *.local domain worked for it, changing on the hosts to

127.0.0.1 site.local
     

I will be editing the answer in more detail about these domains .dev, .local, .foo

    
04.01.2018 / 20:49
4

This will depend on the browser in use.

Chrome is apparently the only one that allows the use of a localhost without SSL via the following flag :

chrome://flags/#allow-insecure-localhost
    
04.01.2018 / 17:16