我正在尝试解决nginx重定向到https的问题,但是当我使用 www.ozkandurakoglu.com 时,我收到414 Request-URI太大错误。这是我对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;
...
}
你可以帮我吗?
谢谢
我回答我的问题,因为我必须同时更改我在问题中没有提到的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;
。}