admin管理员组

文章数量:1404927

I want all traffic going to my web server to be redirected to https on Nginx. However, when I go to my website at , I get the error "414 Request-URI Too Large" and the URL is ridiculously long -- :://www.example/http:: -- and it goes on for a while, which I am assuming is what is giving me this error. But I don't know how to fix this redirection error because my config file for Nginx doesn't contain a $request_uri parameter.

Here's the Nginx config file:

server {
    server_name  example;
    return 301 ;

listen 443 ssl; 
ssl_certificate /etc/letsencrypt/live/example/fullchain.pem; 
ssl_certificate_key /etc/letsencrypt/live/example/privkey.pem; 
include /etc/letsencrypt/options-ssl-nginx.conf; 
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
}

server {
 root /var/www/html;
 ssl_certificate /etc/letsencrypt/live/example/fullchain.pem; # managed by Certbot
 ssl_certificate_key /etc/letsencrypt/live/example/privkey.pem; # managed by Certbot
    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name www.example;
    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            proxy_pass http://localhost:8080; #whatever port your app runs on
            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;      
        }
    }

  
server {
  if ($host = www.example) {
     return 301 ;
  } 


  if ($host = example) {
    return 301 ;
  } 
  listen 80 default_server;
  server_name  example www.example;
  return 404; 
}

Any help would be greatly appreciated!

I want all traffic going to my web server to be redirected to https on Nginx. However, when I go to my website at http://www.example., I get the error "414 Request-URI Too Large" and the URL is ridiculously long -- http://www.example./http:://www.example./http:: -- and it goes on for a while, which I am assuming is what is giving me this error. But I don't know how to fix this redirection error because my config file for Nginx doesn't contain a $request_uri parameter.

Here's the Nginx config file:

server {
    server_name  example.;
    return 301 https://www.example.;

listen 443 ssl; 
ssl_certificate /etc/letsencrypt/live/example./fullchain.pem; 
ssl_certificate_key /etc/letsencrypt/live/example./privkey.pem; 
include /etc/letsencrypt/options-ssl-nginx.conf; 
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
}

server {
 root /var/www/html;
 ssl_certificate /etc/letsencrypt/live/example./fullchain.pem; # managed by Certbot
 ssl_certificate_key /etc/letsencrypt/live/example./privkey.pem; # managed by Certbot
    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name www.example.;
    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            proxy_pass http://localhost:8080; #whatever port your app runs on
            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;      
        }
    }

  
server {
  if ($host = www.example.) {
     return 301 https://www.example.;
  } 


  if ($host = example.) {
    return 301 https://www.example.;
  } 
  listen 80 default_server;
  server_name  example. www.example.;
  return 404; 
}

Any help would be greatly appreciated!

Share Improve this question asked Oct 26, 2020 at 21:17 Max GertnerMax Gertner 791 gold badge1 silver badge4 bronze badges 4
  • Does this answer your question? Request uri too long with webservice – Randy Casburn Commented Oct 26, 2020 at 21:24
  • Hmm, that is a different issue. I just can't figure out what is causing the server to redirect forever until it reaches the limit on http. – Max Gertner Commented Oct 26, 2020 at 21:33
  • Does it still happen when you ment out the proxy directives? Just a guess, but I had this happen with Apache once: The weird redirects came through the proxy. – user1389463 Commented Oct 27, 2020 at 2:24
  • did you fix this?? @MaxGertner – AATHITH RAJENDRAN Commented Apr 1, 2021 at 10:12
Add a ment  | 

2 Answers 2

Reset to default 6

I fix this issue with :

  1. Open your nginx.conf file /etc/nginx/conf.d/nginx.conf

  2. Add this code inside http

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

client_max_body_size 24M;
client_body_buffer_size 128k;

client_header_buffer_size 5120k;
large_client_header_buffers 16 5120k;

  1. Reload your nginx with service nginx reload

I know this is an old question but for anyone looking for a solution, clearing cache & cookies from my browser was the working method.

  1. Open Chrome, at the top right, click the three vertical dots icon.
  2. Click More tools and then Clear browsing data.
  3. At the top, choose a time range. (For me I deleted for the last hour)
  4. Click Clear data.

Source

本文标签: javascriptHow to fix http 414 RequestURI Too Large error on nginxStack Overflow