卡住金字塔請求網址的問題,其中request.static_url
和request.application_url
是2個可識別的嫌疑人。金字塔網址錯誤生成,送達nginx + phusion乘客和Mako模板
在金字塔生成的請求網址以某種方式包括視圖網址,當我把它放在網絡主機上 ,但使用pserve
本地正常工作。
例如:
裏面的真子模板
我:
href="${request.static_url('project:static/blueprint/css/screen.css')}"
應顯示(使用pserve
):
href="http://www.site.com/static/blueprint/css/screen.css"
但在代替它表明:
href="http://www.site.com/view/signin/static/blueprint/css/screen.css"
另一個例子是前網頁網址應顯示:
src = "http://www.site.com/static/img/foo.jpg"
,而是它表明:
src = "http://www.site.com//static/img/foo.jpg"
我目前正在運行的金字塔1.3 +馬可在VPS服務器上使用nginx 0.8.53 + Phusion乘客2.2.15的模板。
這與request.application_url
相同。在視圖代碼我送的字典(url = request.application_url + '/view/signin'
)
該窗體的URL應該顯示:
action="http://www.site.com/view/signin"
相反,它表明:
action="http://www.site.com/view/signin/view/signin"
我已經複製了一些nginx的設置在http://wiki.pylonshq.com/display/pylonscookbook/Running+Pylons+with+NGINX。
特別是:
#site runs on Pylons
location/{
include /usr/local/nginx/conf/proxy.conf;
proxy_pass http://127.0.0.1:8080;
proxy_redirect default;
}
和proxy.conf:
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
我獨自爲它的東西我不想碰別人。
服務器上的nginx.conf看起來像這樣。 (我不使用PHP,但那是我不想碰的東西)。
有人建議將應用程序提供/安裝在/,但我不知道該怎麼做。
server {
listen <ip>:80;
server_name site.com www.site.com;
access_log /<path>/access.log combined;
error_log /<path>/error.log error;
root /home/<path>/public;
index index.html index.htm index.php index.php5;
include /home/<path>/nginx/site.com/*;
# No mirrors - using strict redirects
#if ($http_host != site.com) {
rewrite ^(.*)$ http://site.com$1 permanent;
#}
autoindex on;
passenger_enabled on;
passenger_base_uri /;
# Disallow access to config/VCS data
location ~* /\.(ht|svn) {
deny all;
}
#site runs on Pylons
location/{
include /<path to conf file>/proxy.conf;
proxy_pass http://127.0.0.1:8080;
proxy_redirect default;
}
# Statistics
location /stats/ {
alias /home/<path>/html/;
auth_basic "Statistics Area";
auth_basic_user_file /home/<path>/html/.htpasswd;
}
location /doc/analog/ {
alias /usr/share/analog/;
}
# PHPMyAdmin
rewrite ^/dh_phpmyadmin/([^/]*)/(.*)$ /dh_phpmyadmin/$2;
location /dh_phpmyadmin/ {
alias /dh/web/phpmyadmin/;
}
location ~ /dh_phpmyadmin/(.+)\.php {
alias /dh/web/phpmyadmin/;
fastcgi_param SERVER_PORT 80;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include /dh/nginx/etc/fastcgi_params;
set $relpath "index.php";
if ($uri ~ ^/dh_phpmyadmin/(.+)$) {
set $relpath $1;
}
fastcgi_param SCRIPT_FILENAME /dh/web/phpmyadmin/$relpath;
fastcgi_pass unix:/home/<path>/.php.sock;
}
# PHP
location ~* \.(php|php5|php4)($|/) {
fastcgi_param SERVER_PORT 80;
fastcgi_split_path_info ^(.+\.(?:php|php5|php4))(/.*)$;
if (!-e $document_root$fastcgi_script_name) {
return 404;
}
include /dh/nginx/etc/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/home/<path>/.php.sock;
#pragma php_launch <path>
}
}