主机文件在第一次斜杠

时间:2016-07-28 15:53:31

标签: nginx laravel-5 hosts

我在我的VPS上运行了一个Laravel 5安装,它被用作API。其内部DNS URL为http://brain.#####.co.uk。然后我在我的机器上的hosts文件中创建了一个条目,它将我的请求重定向到我的VPS并从API返回结果。这是我的机器上的主机文件条目(为了安全起见,我已经用has替换了我的地址):

46.**.*.***      brain.#####.co.uk
46.**.*.***      http://brain.#####.co.uk

VPS上的主机文件:

127.0.0.1       brain.#####.co.uk
127.0.0.1       http://#####.co.uk

和我的nGinx服务器阻止:

server {
        listen 80;
        server_name brain.#####.co.uk http://brain.#####.co.uk;

        root /var/www/stdavids-brain/html/public/;
        index index.php index.html;

        sendfile off;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~* \.php {
            include fastcgi_params;

            fastcgi_pass unix:/var/run/php5-fpm.sock;

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_cache off;
            fastcgi_index index.php;
        }
}

我已经检查了这里的所有设置,它们工作正常,当我在Vagrant框中的本地计算机上开发安装时,它工作正常。

我遇到的问题是当我访问网址http://brain.#####.co.uk时,我收到一个很好的Laravel页面,但是当我尝试访问路由http://brain.#####.co.uk/category时,我收到404错误。我已经使用traceroute来ping http://brain.#####.co.uk/category地址,看起来我的请求甚至没有达到我的VPS。当只调用http://brain.#####.co.uk时,它会击中VPS。我知道这条路线存在并正在工作,因为我在本地工作。

我的路线:

+--------+----------+---------------------------------+-------------------------+--------------------------------------------------------------+------------+
| Domain | Method   | URI                             | Name                    | Action                                                       | Middleware |
+--------+----------+---------------------------------+-------------------------+--------------------------------------------------------------+------------+
|        | GET|HEAD | api/v1/category                 | api.v1.category.index   | App\Http\Controllers\CategoryController@index                | cors       |
|        | POST     | api/v1/category                 | api.v1.category.store   | App\Http\Controllers\CategoryController@store                | cors       |
|        | GET|HEAD | api/v1/category/create          | api.v1.category.create  | App\Http\Controllers\CategoryController@create               | cors       |
|        | GET|HEAD | api/v1/category/{category}      | api.v1.category.show    | App\Http\Controllers\CategoryController@show                 | cors       |
|        | PUT      | api/v1/category/{category}      | api.v1.category.update  | App\Http\Controllers\CategoryController@update               | cors       |
|        | DELETE   | api/v1/category/{category}      | api.v1.category.destroy | App\Http\Controllers\CategoryController@destroy              | cors       |
|        | PATCH    | api/v1/category/{category}      |                         | App\Http\Controllers\CategoryController@update               | cors       |
|        | GET|HEAD | api/v1/category/{category}/edit | api.v1.category.edit    | App\Http\Controllers\CategoryController@edit                 | cors       |
|        | GET|HEAD | api/v1/product                  | api.v1.product.index    | App\Http\Controllers\ProductController@index                 | cors       |
|        | POST     | api/v1/product                  | api.v1.product.store    | App\Http\Controllers\ProductController@store                 | cors       |
|        | GET|HEAD | api/v1/product/create           | api.v1.product.create   | App\Http\Controllers\ProductController@create                | cors       |
|        | PUT      | api/v1/product/{product}        | api.v1.product.update   | App\Http\Controllers\ProductController@update                | cors       |
|        | PATCH    | api/v1/product/{product}        |                         | App\Http\Controllers\ProductController@update                | cors       |
|        | GET|HEAD | api/v1/product/{product}        | api.v1.product.show     | App\Http\Controllers\ProductController@show                  | cors       |
|        | DELETE   | api/v1/product/{product}        | api.v1.product.destroy  | App\Http\Controllers\ProductController@destroy               | cors       |
|        | GET|HEAD | api/v1/product/{product}/edit   | api.v1.product.edit     | App\Http\Controllers\ProductController@edit                  | cors       |
|        | POST     | api/v1/status                   | api.v1.status.store     | App\Http\Controllers\StatusController@checkAPIStatus@store   | cors       |
|        | GET|HEAD | api/v1/status                   | api.v1.status.index     | App\Http\Controllers\StatusController@checkAPIStatus@index   | cors       |
|        | GET|HEAD | api/v1/status/create            | api.v1.status.create    | App\Http\Controllers\StatusController@checkAPIStatus@create  | cors       |
|        | GET|HEAD | api/v1/status/{status}          | api.v1.status.show      | App\Http\Controllers\StatusController@checkAPIStatus@show    | cors       |
|        | DELETE   | api/v1/status/{status}          | api.v1.status.destroy   | App\Http\Controllers\StatusController@checkAPIStatus@destroy | cors       |
|        | PATCH    | api/v1/status/{status}          |                         | App\Http\Controllers\StatusController@checkAPIStatus@update  | cors       |
|        | PUT      | api/v1/status/{status}          | api.v1.status.update    | App\Http\Controllers\StatusController@checkAPIStatus@update  | cors       |
|        | GET|HEAD | api/v1/status/{status}/edit     | api.v1.status.edit      | App\Http\Controllers\StatusController@checkAPIStatus@edit    | cors       |
|        | GET|HEAD | images/{file}                   |                         | App\Http\Controllers\ImageController@getImage                |            |
|        | POST     | login                           |                         | App\Http\Controllers\AuthenticateController@authenticate     | cors       |
|        | GET|HEAD | restricted                      |                         | App\Http\Controllers\AuthenticateController@restricted       |            |
|        | POST     | signup                          |                         | App\Http\Controllers\AuthenticateController@signup           | cors       |
+--------+----------+---------------------------------+-------------------------+--------------------------------------------------------------+------------+

有人能看到这里出了什么问题并提供建议吗?

由于

0 个答案:

没有答案