为什么 nginx 会抱怨字母 m?

为什么 nginx 会抱怨字母 m?

所以我有一个用于反向代理的自定义配置文件,当我运行 sudo nginx -t 时,我得到了

nginx: [emerg] unexpected "m" in /etc/nginx/sites-enabled/<domain>.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed

下面是我在继续之前尝试传递的配置内容或块。

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name <server_url>;
    ssl_certificate /config/.acme.sh/your-domain/fullchain.cer;
    ssl_certificate_key /config/.acme.sh/your-domain/your-domain.key;
    access_log /var/log/nginx/<server_url>.access.log;
    error_log /var/log/nginx/<server_url>.error.log;          
    ssl_session_timeout 1d;          
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;         
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-S$         
    ssl_prefer_server_ciphers on;         
    ssl_session_cache shared:SSL:10m;  
    #dh param         
    ssl_dhparam /config/ssl/dhparam.pem;  
    # Enable HTTP Strict-Transport-Security 
    # If you have a subdomain of your site, 
    # be careful to use the 'includeSubdomains' options         
    add_header Strict-Transport-Security "max-age=63072000; 
    includeSubdomains; preload";  
    # XSS Protection for Nginx web server         
    add_header X-Frame-Options DENY;         
    add_header X-XSS-Protection "1; mode=block";         
    add_header X-Content-Type-Options nosniff;         
    ssl_session_cache shared:SSL:10m;         
    add_header X-Robots-Tag none;    
    client_max_body_size 0;   
    proxy_http_version 1.1;   
    proxy_buffering off;   
    proxy_set_header Upgrade $http_upgrade;   
    proxy_set_header Connection "Upgrade";   
    proxy_set_header Host $host;   
    proxy_set_header X-Real-IP $remote_addr;   
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;    
    location / {     
        proxy_pass https://<ip_address>;   
    } 
}   

从理论上来说,add_header 行应该是第 19 行。

思考

谢谢。

JR

答案1

您从某个编辑器中复制了 ssl_ciphers 行,但该编辑器将其截断为刚好适合窗口的内容。请注意,该行的结尾基本上是ECDHE-RSA-AES256-GCM-S$– 这不是有效的密码名称。更重要的是,这也不是结束引号。

这意味着一切直到包括... Strict-Transport-Security仍然是密码列表的一部分,并且之前的引号max-age不是开头的引号——而是结尾的引号。你基本上有:

ssl_ciphers "blah blah blah "max-age=63072000;

相关内容