Welcome! Log In Create A New Profile

Advanced

How Do I Show Only The Domain Name in the Address Bar

Posted by pointnginx 
How Do I Show Only The Domain Name in the Address Bar
March 09, 2023 08:27PM
I have an app that I have placed behind NGINX as a reverse proxy and everything is working great except for...

I can't work out how to have the address bar on a browser only show the domain name and not the path

For example my server returns things like

sub.domain.com/BNS/Panel/1/stuff

This is not meaningful for a user and a user would never type this in, so I would like to restrict the browser address bar to only show

sub.domain.com

I've been searching high and low but with no success.

The current directive looks like this:

server {
server_name sub.domain.com;

location = / {
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://1.2.3.4:8080/path/file.html;
proxy_cookie_path ~*^/.* /;
proxy_intercept_errors on;
}

location / {
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://1.2.3.4:8080/path/file.html;
proxy_cookie_path ~*^/.* /;
proxy_intercept_errors on;
}

listen 443 ssl; # managed by Certbot
ssl_certificate path/to/key.pem; # managed by Certbot
ssl_certificate_key path/to/key.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = sub.domain.com) {
return 301 https://$host;
} # managed by Certbot

server_name sub.domain.com;
listen 80;
return 404; # managed by Certbot
}

Thanks for any assistance or links to somewhere I haven't found yet.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 240
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready