我正在尝试将nginx重定向解决为https但是当我使用www.ozkandurakoglu.com时,我收到414 Request-URI Too Large错误。这是我对nginx的设置:
upstream ozkan_server {
server unix:/home/ytsejam/public_html/ozkansimple/run/gunicorn.sock fail_timeout=10s;
}
server {
listen 80;
server_name ozkandurakoglu.com www.ozkandurakoglu.com;
return 301 $scheme:https://ozkandurakoglu.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/ozkandurakoglu.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ozkandurakoglu.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/ozkandurakoglu.com/chain.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name www.ozkandurakoglu.com;
return 301 $scheme:https://ozkandurakoglu.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/ozkandurakoglu.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ozkandurakoglu.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/ozkandurakoglu.com/chain.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name www.ozkandurakoglu.com ozkandurakoglu.com;
client_max_body_size 4G;
root /home/ytsejam/public_html/ozkansimple/;
access_log /home/ytsejam/public_html/ozkansimple/logs/nginx-access.log;
error_log /home/ytsejam/public_html/ozkansimple/logs/nginx-error.log warn;
large_client_header_buffers 6 16k;
...
}
你可以帮帮我吗?
由于
答案 0 :(得分:2)
我回答我的问题,因为我必须更改我在问题中未提及的nginx和gunicorn,我已在服务器块中删除$cheme
server {
listen 80;
server_name ozkandurakoglu.com www.ozkandurakoglu.com;
return 301 https://ozkandurakoglu.com$request_uri;
}
并添加
limit_request_line
--limit-request-line INT
4094
The maximum size of HTTP request line in bytes.
到我的枪口起跑线。
编辑:最后几天正确设置后
server {
listen 80;
server_name ozkandurakoglu.com www.ozkandurakoglu.com;
return 301 https://www.ozkandurakoglu.com$request_uri;
}
server {
listen 443 ssl http2;
server_name ozkandurakoglu.com;
return 301 https://www.ozkandurakoglu.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.ozkandurakoglu.com;
access_log /var/log/nginx/ozkandurakoglu.com.access.log;
error_log /var/log/nginx/ozkandurakoglu.com.error.log;
ssl_certificate /etc/letsencrypt/live/www.ozkandurakoglu.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.ozkandurakoglu.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/www.ozkandurakoglu.com/chain.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:64m;
ssl_session_tickets off;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-$
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload";
ssl_stapling on;
ssl_stapling_verify on;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy no-referrer-when-downgrade;
#add_header Content-Security-Policy "default-src https:";
resolver 8.8.8.8 8.8.4.4;
resolver_timeout 5s;
client_max_body_size 4G;
... }