我剛剛設置了Nginx,我試圖用它來託管一個Laravel應用程序,但我遇到了兩個問題。帶Nginx參數的Laravel是空的
- 對於GET方法,我總是會在我的輸入中獲得一個額外的參數。
- 使用PostMan(Chrome)進行測試,我設置了目標URL和我想要的參數併發送請求。我得到的輸出總是包含
REQUEST_URI
,它不應該。示例輸出:
- 使用PostMan(Chrome)進行測試,我設置了目標URL和我想要的參數併發送請求。我得到的輸出總是包含
。
Array (
[/api/user] => // This shouldn't be here
[test] => test
)
- 我的參數(以上)的DELETE將不節目或PUT,在所有的,以及POST我只得到
REQUEST_URI
Nginx的虛擬主機(隨後Setting up Laravel w/ Nginx)
server {
server_name local.test.com;
root /var/www/test/public;
location/{
index index.php index.html index.htm;
}
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# catch all
error_page 404 /index.php;
# The PHP Inclusion Block
# include /etc/nginx/includes/php;
location ~ \..*/.*\.php$ {
# I'm pretty sure this stops people trying to traverse your site to get to other PHP files
return 403;
}
#location ~ \.php$ {
location ~ \.php(.*)$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
# Deny Any Access to .htaccess Files That May Be Present (not usually in issue in Laravel)
# include /etc/nginx/includes/deny_htaccess;
location ~ /\.ht
{
deny all;
}
error_log /var/www/logs/test-error.log;
}
fastcgi_params:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
#fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
nginx.conf只有1個的東西改變,那就是從65 keepalive_timeout
至15
所以我絕對不知道,所有的這件事情不順心。但我不得不提一提,在另外兩個環境中(一個使用Lighttpd,另一個使用Apache2),該應用程序完美無缺。
從我注意到,它的所有歸納爲以下代碼:
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
這將使找份工作......並添加附加參數
'DD對我的作品的配置(輸入::所有());'這就是我」 m輸出...並且不是,它不是'Input :: all()',它設置了不需要的參數 – Alex 2013-02-13 13:18:40
好的。嘗試建議的配置,並告訴我是否它。 – Gargron 2013-02-13 13:23:45
剛剛嘗試過,通過評論包含重寫規則的「if」,現在我根本沒有輸出我的參數 – Alex 2013-02-13 13:24:45