yuanrui / blog

Some notes.
http://yuanrui.github.io
3 stars 0 forks source link

nginx启动报错 #37

Open yuanrui opened 3 years ago

yuanrui commented 3 years ago

在启动nginx时报如下错误:

nginx: [emerg] CreateFile() "D:\Work\XX项目\nginx-1.20.1/conf/nginx.conf" failed (1113: No mapping for the Unicode character exists in the target multi-byte code page)

原因是启动目录包含中文,在将目录修改为全英文目录后,启动正常。

Update at:2021-06-29 采用nginx进行路径映射,启动报proxy_pass相关错误

nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in D:\Work\nginx-1.20.1/conf/nginx.conf:49

原始的路径转换规则是:

        location  ~ (^/13.132.175.150:28008).*  {
            proxy_pass http://13.132.175.150:28008/;
            proxy_set_header Host                $host:$server_port;
            proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto   $scheme;
            proxy_set_header X-Forwarded-Port    $server_port;
        }

这个转换包含正则表达式,去掉正则表达式直接进行路径匹配可以解决该问题。

        location /13.132.175.150:28008/ {
            proxy_pass http://13.132.175.150:28008/;
            proxy_set_header Host                $host:$server_port;
            proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto   $scheme;
            proxy_set_header X-Forwarded-Port    $server_port;
        }