簡體   English   中英

Nginx網址重寫錯誤:[emerg]意外的“}”

[英]Nginx url rewrite error : [emerg] unexpected “}”

我正在嘗試在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;
            ...
        }
    }
}

我正在使用DirectAdmin,當我從linux或DirectAdmin手動添加此代碼塊時,遇到相同的錯誤:

nginx:/usr/local/directadmin/data/users/admin/nginx.conf中的[emerg]意外的“}”:178 nginx:配置文件/etc/nginx/nginx.conf測試失敗

注意:我要從此處復制粘貼此代碼的穩定性

而且我懷疑問題是3個點(...)所在的位置(在fastcgi_pass 127.0.0.1:8080; )我認為我應該在這里添加一些我不知道的東西?

我在此代碼塊中缺少什么?
還是還有另一個我遇到此錯誤的問題?
預先感謝任何幫助我解決此問題的人:)

問題是你想念; try_files的末尾。
但這也無濟於事。
如您所提到的,您正在使用DirectAdmin,建議您使用Nginx - Apache Reverse proxy
首先確保您有custombuild 2

cd /usr/local/directadmin/custombuild
./build version

您應該看到類似於以下內容的輸出:

2.0.0-RC7 (rev: 863)

另外,請確保Directadmin的版本不少於1.45.2,否則將無法正常工作。

/usr/local/directadmin/directadmin v

運行以下代碼以使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM