Archivo de descargas de proxy Nginx sin “http://”

Archivo de descargas de proxy Nginx sin “http://”

Creé un proyecto con Laravel API y NuxtJS (SSR)

Lo implementé en un servidor AWS que ejecuta Ubuntu (18.04 LTS). Mi problema es que cada vez que voy al enlace "ejemplo.com", descargaré un archivo, pero cada vez que agrego, por ejemplo, un http:// o https://, funciona normalmente.

Aquí está mi bloque de servidor:

# Default

map $sent_http_content_type $expires {
        "text/html"                     epoch;
        "text/html; charset=utf-8"      epoch;
        default                         off;
}

server {
    # listen [::]:80 ssl http2;
    server_name example.com www.example.com;

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    # Logs
    access_log /var/log/nginx/example.com_access.log;
    error_log /var/log/nginx/example.com_error.log;

    location / {

        expires $expires;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass                          http://127.0.0.1:3000;
        proxy_http_version                  1.1;
        proxy_set_header                    upgrade $http_upgrade;
        proxy_set_header                    Connection 'upgrade';
        proxy_set_header                    Host $host;
        proxy_cache_bypass                  $http_upgrade;

        proxy_redirect                      off;

    }

    location ~ /\.{
        access_log off;
        log_not_found off;
        deny all;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.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 = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 http2;
    server_name example.com www.example.com;
    return 404; # managed by Certbot
}

Respuesta1

Arreglado cambiando

server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 http2;
    server_name example.com www.example.com;
    return 404; # managed by Certbot
}

a:

server {
    listen 80 default_server;

    server_name example.com www.example.com

    return 301 https://$host$request_uri
}

información relacionada