[英]Nginx url rewrite error : [emerg] unexpected “}”
I'm trying to rewrite urls in nginx, blow is my sample code : 我正在尝试在nginx中重写网址,打击是我的示例代码:
server {
listen 80;
server_name example.com;
root /full/server/path/to/your/cms;
index index.php;
location / {
try_files $uri $uri/ /phphandler
}
location /phphandler {
internal;
# nested location to filter out static items not found
location ~ .php$ {
rewrite ^/([^/]*)(.*) /$1 break;
fastcgi_pass 127.0.0.1:8080;
...
}
}
}
I'm using DirectAdmin and when I add this block of code manually from linux or from DirectAdmin, I face the same error : 我正在使用DirectAdmin,当我从linux或DirectAdmin手动添加此代码块时,遇到相同的错误:
nginx: [emerg] unexpected "}" in /usr/local/directadmin/data/users/admin/nginx.conf:178 nginx: configuration file /etc/nginx/nginx.conf test failed
nginx:/usr/local/directadmin/data/users/admin/nginx.conf中的[emerg]意外的“}”:178 nginx:配置文件/etc/nginx/nginx.conf测试失败
Notice : I'm copy pasting this peace of code from Here 注意:我要从此处复制粘贴此代码的稳定性
And I'm in doubt that the problem is where the 3 dots( ... ) are ( after fastcgi_pass 127.0.0.1:8080;
) I think there's some thing I should add here that I don't know?! 而且我怀疑问题是3个点(...)所在的位置(在
fastcgi_pass 127.0.0.1:8080;
)我认为我应该在这里添加一些我不知道的东西?
Is there anything I'm missing in this block of code? 我在此代码块中缺少什么?
Or there's another problem that I face this error? 还是还有另一个我遇到此错误的问题?
Thanks in advance from anyone who helps me solve this problem :) 预先感谢任何帮助我解决此问题的人:)
The problem is that you miss ;
问题是你想念
;
at the end of the try_files
. 在
try_files
的末尾。
But also this doesn't help much too. 但这也无济于事。
As you mentioned you're using DirectAdmin I recommend you use Nginx - Apache Reverse proxy
. 如您所提到的,您正在使用DirectAdmin,建议您使用
Nginx - Apache Reverse proxy
。
First of all make sure you've got custombuild 2 首先确保您有custombuild 2
cd /usr/local/directadmin/custombuild
./build version
You should see an output similar to the following: 您应该看到类似于以下内容的输出:
2.0.0-RC7 (rev: 863)
Also make sure to have version of directadmin no less than 1.45.2 otherwise the things won't work. 另外,请确保Directadmin的版本不少于1.45.2,否则将无法正常工作。
/usr/local/directadmin/directadmin v
Run this code to build nginx + apache with custombuild: 运行以下代码以使用custombuild构建Nginx + Apache:
cd /usr/local/directadmin/custombuild
./build update
./build update_da
./build set webserver nginx_apache
./build nginx_apache
./build rewrite_confs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.