A
A
Alexey Yarkov2020-09-18 13:55:16
Nginx
Alexey Yarkov, 2020-09-18 13:55:16

How to remove the slash after the domain?

Locally set up https and the dev.nuxt domain for work.
If I open some route, then there is no slash ( https://dev.nuxt/profile ).
And if I open the site root, then a slash after the domain ( https://dev.nuxt/ ).

Nginx config:

upstream nuxt_app {
    server 127.0.0.1:3000;
}

server {
    listen 443 ssl http2;
    server_name dev.nuxt www.dev.nuxt;

    ssl_certificate_key       /etc/nginx/ssl/dev.nuxt.key;
    ssl_certificate           /etc/nginx/ssl/dev.nuxt.crt;
    ssl_dhparam               /etc/nginx/dhparam.pem;
    ssl_session_cache         shared:SSL:1m;
    ssl_protocols             TLSv1.2;
    ssl_ciphers               ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384;
    ssl_prefer_server_ciphers on;

    if (!-f $request_filename) {
        rewrite ^/(.*)/$ /$1 permanent;
    }

    location = /favicon.ico {
        access_log     off;
        log_not_found  off;
    }

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme; 
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_read_timeout 5m;
        proxy_connect_timeout 5m;
        proxy_pass http://nuxt_app;
        proxy_redirect off;
    }
}

server {
    listen 80;
    server_name dev.nuxt www.dev.nuxt;

    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Connection "";

    location / {
        return 301 https://$server_name$request_uri;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vreitech, 2020-09-18
@fzfx

There will always be a slash after the domain, and nothing can be done about it. it is part of the implementation of the HTTP protocol.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question