Ticket #231 (closed defect: invalid)

Opened 3 months ago

Last modified 3 months ago

Wrong url mapping with FastCGI and lighttpd

Reported by: guest Owned by: jens
Priority: minor Milestone: v0.9
Component: system Keywords: FastCGI lighttpd
Cc: frank.tegtmeyer@…

Description

It seems that the URL (back-)mapping is broken in some places when using FastCGI and lighttpd.

Here is my lighttpd setup (used also in other Django setups):

   $HTTP["host"] =~ "(xxx.xxx.xxx)|(yyy.yyy.yyy)" {
     server.document-root = "/media/internet/fake_documentroot/"

     # aliases
     alias.url = (
         "/media/" => "/media/internet/media/",
         "/admin/media/" => "/media/internet/django/contrib/admin/media/",
     )

     # rewrites
     url.rewrite-once = (
          "^(/media/.*)$" => "$1",
          "^(/static/.*)$" => "$1",
          "^(/internet.fcgi/.*)$" => "$1",
          "^(.*)$" => "/internet.fcgi$1",
     )

     # FastCGI - Setup
     #fastcgi.debug = 1
     fastcgi.server = (
          "/internet.fcgi" => (
              (
              "host" => "127.0.0.1",
              "port" => 6978,
              "check-local" => "disable",
              ),
          )
     )

   }

There are two problems:

1. The script name (internet.fcgi) is used in front of generated links sometimes (that's why the rewrite-once rule is used for this).
Example in the django panel edit for a page:

<div id="user-tools">Willkommen, <strong>Frank</strong>.
<a href="/internet.fcgi/_admin/doc/">Dokumentation</a> /
<a href="/internet.fcgi/_admin/password_change/">Passwort ändern</a> /
<a href="/internet.fcgi/_admin/logout/">Abmelden</a></div>

2. Some media links contain the physical path instead of the mapped URL.
Example in the django panel edit for a page:

<a href="../../../PyLucid/page/add/" class="add-another"
   id="add_id_parent" onclick="return showAddAnotherPopup(this);">
 <img src="/media/internet/django/contrib/admin/media/img/admin/icon_addlink.gif"
  width="10" height="10" alt="Add Another"/></a>

The correct link to the image would be:

/admin/media/img/admin/icon_addlink.gif

I didn't do a complete check where this happens, sorry.

With kind regards,
Frank Tegtmeyer <frank.tegtmeyer@…>

Change History

Changed 3 months ago by JensDiemer

I don't know if you url rewrite rules are correct. I have no experience with lighttpd. This two lines seems to be wrong:

          "^(/internet.fcgi/.*)$" => "$1",
          "^(.*)$" => "/internet.fcgi$1",

With the new changeset:1775 i have hacked a url info into the _install section. You can find it under "4. some tests" / "5. Display the current used urlpatterns"

In my dev.environment it looks like this:

       pylucid_media_root: './media/PyLucid'
custom_internal_page_root: './media/PyLucid/custom'
       internal_page_root: './media/PyLucid/internal_page'
                  docRoot: '/'
               scriptRoot: '/'
                adminBase: '/_admin'
                path_info: '/_install/tests/url_info/'
                      cwd: '/home/jens/workspace/PyLucid_trunk/pylucid_project'
        PyLucid_media_url: '/media/PyLucid'
 custom_internal_page_url: '/media/PyLucid/custom'
        internal_page_url: '/media/PyLucid/internal_page'
                     host: '127.0.0.1:8000'
                 hostname: 'http://127.0.0.1:8000'
            absoluteIndex: 'http://127.0.0.1:8000/'

You can also find this information, if you can login into your PyLucid installation. goto: "sub menu" / "miscellaneous" / "Show internals" / "PyLucid info"

For the media path, you should check the MEDIA_URL in your settings.py: http://trac.pylucid.net/browser/trunk/pylucid/PyLucid/settings_example.py?rev=1634#L157

Please note: PyLucid must exist into the url root and you should start the request without /internet.fcgi! e.g.: not "domain.tld/internet.fcgi" -> only: "domain.tld/"

Changed 3 months ago by JensDiemer

btw. this should be discussed into our forum: http://www.pylucid.org/phpBB2/ ;)

Changed 3 months ago by guest

  • status changed from new to closed
  • resolution set to invalid

Hi,

the problems are solved - my error. The ADMIN_MEDIA_PREFIX in settings.py was set to the physical path instead of the URL prefix. Interestingly this affected both the image link and the generated management links.

Thanks for your patience and for the software!

Frank

Note: See TracTickets for help on using tickets.