How to create a catch all https "default_server" for "Welcome to Nginx!" Page, using self signed certificate in /etc/nginx/conf.d/default.conf
0
votes
0
answers
233
views
I am running a LEMP server with Nginx, and have the "
listen 80 default_server;
" directive enabled for port 80 in the catch all /etc/nginx/conf.d/default.conf
directive. When I browse to the url: http://my.servers.ip.address , the server automatically redirects to a page that says
> Welcome to nginx! If you see this page, the nginx web server is
> successfully installed and working. Further configuration is required.
>
> For online documentation and support please refer to nginx.org.
> Commercial support is available at nginx.com.
> Thank you for using nginx.
However, in my default.conf file, I only have 'default_server
' enabled for port 80, because I don't have a https certificate for my servers IP address.
So, When I go to https://my.servers.ip.address , instead of Nginx directing me toward a secure version of the default Nginx Welcome page, it directs me to my first valid virtual hosts https address, giving me a
> Connection Is Not Private This website may be impersonating
> "my.servers.ip.address" to steal your personal of financial
> information. you should go back to the previous page.
notice first.
What I would like Nginx to do is have a "default_server" option in Nginx's default.conf for "listen 443 default_server
;" directive, so that when I go to https://my.server.ip.address in a web browser, it goes to a self signed secure version of the default "Welcome to Nginx!" page, instead of one of my virtual host's domains.
So my question is, how do I implement a catch all "default_server" in /etc/conf.d/default.conf for https, using self signed certificates, instead of default.conf redirecting to the https address of my first virtual host?
Below is my /etc/nginx/default.conf file.
server {
listen 80 default_server;
server_name _;
root /var/www/html/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
}
# A long browser cache lifetime can speed up repeat visits to your page
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
# disable access to hidden files
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
}
Asked by DanRan
(113 rep)
Jul 18, 2023, 05:07 AM