I am using NGINX for 301 redirects on Ubuntu and reverse proxy for my Web Application and aim is to redirect traffic to non-www url such as https://mywebapplication.example
.
So with my current config for NGINX Conf File:
mywebapplication.example -> https://mywebapplication.example
www.mywebapplication.example -> https://mywebapplication.example
http://mywebapplication.example -> https://mywebapplication.example
http://www.mywebapplication.example -> https://mywebapplication.example
192.0.2.123 -> https://mywebapplication.example
http://192.0.2.123 -> https://mywebapplication.example
Works fine but when IP with HTTPS is provided in the URL, I get "Your connection is not private."
https://192.0.2.123 -> Your connection is not private
Here's my NGINX Conf.
server {
listen 192.0.2.123:80;
location / {
proxy_pass "http://localhost:4000/";
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
server {
listen 192.0.2.123:80;
server_name 192.0.2.123 192.0.2.123:4000;
return 301 https://mywebapplication.example$request_uri;
}
server {
listen 80 http2;
listen [::]:80 http2;
server_name mywebapplication.example www.mywebapplication.example;
return 301 https://mywebapplication.example$request_uri;
}
server {
listen 443 ssl http2;
server_name www.mywebapplication.example;
return 301 https://mywebapplication.example$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name mywebapplication.example;
...
...
...
...
}
How can I handle IP with HTTPS to a successful 301 redirection?
123.456.789.123
is certainly not an IPv4 address. I edited your post using appropriate values. 2) you get the error because there is no X509 certificate provided for the given IP address, which is "normal" in the sense that while technically possible, certificates are used for names, not addresses in the HTTPS world. Instead of trying to do that, just configure your webserver to not reply when the SNI/Host information is absent (or live with the error message, noone should enter such URLs with IPs anyway).Https version of IP
, so when a user clicks/navigates with that URL this problem persists. Any solution to this particular scenario? Thanking You! and thanks @dan, I saw the migration you made.