Pull request: all: do not redirect to https if not necessary

Merge in DNS/adguard-home from 3558-https-redirect to master

Squashed commit of the following:

commit f656563c0b0db6275748de28bc890dcf85b0e398
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Dec 10 20:44:00 2021 +0300

    all: do not redirect to https if not necessary
This commit is contained in:
Ainar Garipov 2021-12-13 13:48:08 +03:00
parent 86cffcd168
commit a396865869
3 changed files with 6 additions and 3 deletions

View File

@ -125,6 +125,8 @@ In this release, the schema version has changed from 10 to 12.
### Fixed
- Invalid redirection to the HTTPS web interface after saving enabled encryption
settings ([#3558]).
- Incomplete propagation of the client's IP anonymization setting to the
statistics ([#3890]).
- Incorrect `$dnsrewrite` results for entries from the operating system's hosts
@ -217,6 +219,7 @@ In this release, the schema version has changed from 10 to 12.
[#3529]: https://github.com/AdguardTeam/AdGuardHome/issues/3529
[#3538]: https://github.com/AdguardTeam/AdGuardHome/issues/3538
[#3551]: https://github.com/AdguardTeam/AdGuardHome/issues/3551
[#3558]: https://github.com/AdguardTeam/AdGuardHome/issues/3558
[#3564]: https://github.com/AdguardTeam/AdGuardHome/issues/3564
[#3567]: https://github.com/AdguardTeam/AdGuardHome/issues/3567
[#3568]: https://github.com/AdguardTeam/AdGuardHome/issues/3568

View File

@ -301,10 +301,10 @@ export const redirectToCurrentProtocol = (values, httpPort = 80) => {
const {
protocol, hostname, hash, port,
} = window.location;
const { enabled, port_https } = values;
const { enabled, force_https, port_https } = values;
const httpsPort = port_https !== STANDARD_HTTPS_PORT ? `:${port_https}` : '';
if (protocol !== 'https:' && enabled && port_https) {
if (protocol !== 'https:' && enabled && force_https && port_https) {
checkRedirect(`https://${hostname}${httpsPort}/${hash}`);
} else if (protocol === 'https:' && enabled && port_https && port_https !== parseInt(port, 10)) {
checkRedirect(`https://${hostname}${httpsPort}/${hash}`);

View File

@ -140,7 +140,7 @@ type dnsConfig struct {
type tlsConfigSettings struct {
Enabled bool `yaml:"enabled" json:"enabled"` // Enabled is the encryption (DoT/DoH/HTTPS) status
ServerName string `yaml:"server_name" json:"server_name,omitempty"` // ServerName is the hostname of your HTTPS/TLS server
ForceHTTPS bool `yaml:"force_https" json:"force_https,omitempty"` // ForceHTTPS: if true, forces HTTP->HTTPS redirect
ForceHTTPS bool `yaml:"force_https" json:"force_https"` // ForceHTTPS: if true, forces HTTP->HTTPS redirect
PortHTTPS int `yaml:"port_https" json:"port_https,omitempty"` // HTTPS port. If 0, HTTPS will be disabled
PortDNSOverTLS int `yaml:"port_dns_over_tls" json:"port_dns_over_tls,omitempty"` // DNS-over-TLS port. If 0, DoT will be disabled
PortDNSOverQUIC int `yaml:"port_dns_over_quic" json:"port_dns_over_quic,omitempty"` // DNS-over-QUIC port. If 0, DoQ will be disabled