Giter VIP home page Giter VIP logo

Comments (14)

sametmax avatar sametmax commented on June 14, 2024

0bin is made to work anywhere but root, so there something in your
settings that is weird. Please post your dir tree, apache conf file,
wsgi file, setting file and anything useful in a paste bin if you want
help.

Le ven. 12 juil. 2013 21:47:47 CEST, toQ a écrit :

I am curious if there is a way to allow 0bin be run behind a web
server at a non-root path, e.g.: http://example.com/path/to/0bin

I've been toying with Apache with mod_proxy and mod_wsgi, and I keep
getting errors with wanting to load resources from '/' (like /static
or /create) when the server path is not at '/' but at some other location.


Reply to this email directly or view it on GitHub
#52.

from 0bin.

 avatar commented on June 14, 2024

Hi,

I have git sources checked out under 0bin at: /opt/0bin

Here are my options for the two methods I attempted:

mod_proxy

When using mod_proxy I first start 0bin in /opt/0bin via:
python zerobin.py --host 127.0.0.1 --port 8000 --compressed-static

I then have an apache virtual host for the mod_proxy method:

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass /paste/ http://127.0.0.1:8000/
        ProxyPassReverse /paste/ http://127.0.0.1:8000/
</VirtualHost>

WSGI

My app.wsgi in /opt/0bin/zerobin (taken right from the docs):

import os, sys

# make sure the zerobin module is in the PYTHON PATH and importable
ZEROBIN_PARENT_DIR = os.path.dirname(os.path.dirname(__file__))
sys.path.insert(0, ZEROBIN_PARENT_DIR)

# create the wsgi callable
from zerobin.routes import get_app
settings, application = get_app(compressed_static=True)

And my apache virtual host for WSGI:

<VirtualHost *:80>
    WSGIDaemonProcess zerobin processes=1 threads=5
    WSGIScriptAlias /paste/ /opt/0bin/zerobin/app.wsgi

    <Directory /opt/0bin/zerobin/>
        WSGIProcessGroup zerobin
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

In both cases I receive resource errors like this:
[Fri Jul 12 12:58:58 2013] [error] [client SCRUBBED] File does not exist: /srv/www/htdocs/static, referer: http://SCRUBBED/paste/

However with WSGI, when trying to create a paste I got an error like this:
[Fri Jul 12 13:00:02 2013] [error] [client SCRUBBED] Target WSGI script not found or unable to stat: /opt/0bin/zerobin/app.wsgicreate, referer: http://SCRUBBED/paste/

Note that mod_wsgi and mod_proxy are both enabled and working fine. Both of these attempts will let me hit my website at /paste/ but none of the resources are loaded (so no styles) or actions work (no paste creation).

from 0bin.

Natim avatar Natim commented on June 14, 2024

I understood what you mean.
We need to have a look at the html files and the way we are loading resource files there.

from 0bin.

sametmax avatar sametmax commented on June 14, 2024

I also need the settings file and you dir tree. Also you probably want to serve the static files with apache instead of zerobin since you are using it. It will be much more performant.

from 0bin.

 avatar commented on June 14, 2024

I am using the raw git source from master, with an untouched zerobin/default_settings.py. I have made no other changes to the source tree other than adding the app.wsgi

from 0bin.

 avatar commented on June 14, 2024

I just realized you mean my apache configuration. I am using an almost untouched default-server.conf on an openSUSE server. Here it is:

#
# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
# 

DocumentRoot "/srv/www/htdocs"

#
# Configure the DocumentRoot
#
<Directory "/srv/www/htdocs">
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs-2.2/mod/core.html#options
        # for more information.
        ##Options None
Options Indexes FollowSymLinks
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
AllowOverride None
        # Controls who can get stuff from this server.
Order allow,deny
 Allow from all
</Directory>

# Aliases: aliases can be added as needed (with no limit). The format is 
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the 
# realname must also be slash terminated, and if the fakename omits the 
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
 Options Indexes MultiViews
 AllowOverride None
 Order allow,deny
 Allow from all
</Directory>

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/srv/www/cgi-bin">
 AllowOverride None
 Options +ExecCGI -Includes
 Order allow,deny
 Allow from all
</Directory>

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES 
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
        # Note that the name of the user directory ("public_html") cannot simply be
        # changed here, since it is a compile time setting. The apache package
        # would have to be rebuilt. You could work around by deleting
        # /usr/sbin/suexec, but then all scripts from the directories would be
        # executed with the UID of the webserver.
UserDir public_html
        # The actual configuration of the directory is in
        # /etc/apache2/mod_userdir.conf.
Include /etc/apache2/mod_userdir.conf
</IfModule>


# Include all *.conf files from /etc/apache2/conf.d/.
#
# This is mostly meant as a place for other RPM packages to drop in their
# configuration snippet.
#
# You can comment this out here if you want those bits include only in a
# certain virtual host, but not here.
#
Include /etc/apache2/conf.d/*.conf

# The manual... if it is installed ('?' means it won't complain)
Include /etc/apache2/conf.d/apache2-manual?conf
ServerName SCRUBBED

ServerAdmin root@SCRUBBED

from 0bin.

sametmax avatar sametmax commented on June 14, 2024

Wow, I completly forgot about this ticket. Very very very sorry.

Is that still an issue ?

Le mar. 16 juil. 2013 17:55:51 CEST, toQ a écrit :

I just realized you mean my apache configuration. I am using an almost
untouched default-server.conf on an openSUSE server. Here it is:

|#

Global configuration that will be applicable for all virtual hosts, unless

deleted here, or overriden elswhere.

DocumentRoot "/srv/www/htdocs"

Configure the DocumentRoot

<Directory "/srv/www/htdocs">
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named explicitly --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
##Options None
Options Indexes FollowSymLinks
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride None
# Controls who can get stuff from this server.
Order allow,deny
Allow from all

Aliases: aliases can be added as needed (with no limit). The format is

Alias fakename realname

Note that if you include a trailing / on fakename then the server will

require it to be present in the URL. So "/icons" isn't aliased in this

example, only "/icons/". If the fakename is slash-terminated, then the

realname must also be slash terminated, and if the fakename omits the

trailing slash, the realname must also omit it.

We include the /icons/ alias for FancyIndexed directory listings. If you

do not use FancyIndexing, you may comment this out.

Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

ScriptAlias: This controls which directories contain server scripts.

ScriptAliases are essentially the same as Aliases, except that

documents in the realname directory are treated as applications and

run by the server when requested rather than as documents sent to the client.

The same rules about trailing "/" apply to ScriptAlias directives as to

Alias.

ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"

"/srv/www/cgi-bin" should be changed to whatever your ScriptAliased

CGI directory exists, if you have that configured.

<Directory "/srv/www/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all

UserDir: The name of the directory that is appended onto a user's home

directory if a ~user request is received.

To disable it, simply remove userdir from the list of modules in APACHE_MODULES

in /etc/sysconfig/apache2.

# Note that the name of the user directory ("public_html") cannot simply be # changed here, since it is a compile time setting. The apache package # would have to be rebuilt. You could work around by deleting # /usr/sbin/suexec, but then all scripts from the directories would be # executed with the UID of the webserver. UserDir public_html # The actual configuration of the directory is in # /etc/apache2/mod_userdir.conf. Include /etc/apache2/mod_userdir.conf

Include all *.conf files from /etc/apache2/conf.d/.

This is mostly meant as a place for other RPM packages to drop in their

configuration snippet.

You can comment this out here if you want those bits include only in a

certain virtual host, but not here.

Include /etc/apache2/conf.d/*.conf

The manual... if it is installed ('?' means it won't complain)

Include /etc/apache2/conf.d/apache2-manual?conf
ServerName SCRUBBED

ServerAdmin root@SCRUBBED
|


Reply to this email directly or view it on GitHub
#52 (comment).

from 0bin.

pjz avatar pjz commented on June 14, 2024

I'm having a problem with this too, but I'm using nginx. I run 0bin on localhost:7001 and then do:

location /zerobin/ {
    proxy_pass http://localhost:7001/;
    proxy_redirect default;
}

which should do it, right? But it fails because all the references to css and etc are to '/static/css/..', which isn't there, and the javascript posts to '/paste/create' which likewise isn't the right place. Am I missing some additional necessary config somewhere?

from 0bin.

pjz avatar pjz commented on June 14, 2024

I was able to get it working a bit by removing leading slashes from the templates under views/ and also from the js under static/js (references to /static/ and /paste/create mostly), but that seems a bit unmaintainable. Is there an easier way?

from 0bin.

pjz avatar pjz commented on June 14, 2024

So now I can paste but not retrieve, since the URL relpath changes onces there's been a paste, such that 'static/...' is no longer correct. It should be '../static/...' or somesuch. sigh I guess I wait for a real fix. My minimal research indicates you should be using get_url(...) somewhere? I don't grok bottle, really. Failing that, maybe let us specify a base URL (or directory?) in the settings.py file? ROOT_URL="/zerobin/" for instance; default is ROOT_URL='/' of course.

from 0bin.

omyno avatar omyno commented on June 14, 2024

@pjz Did you ever find a solution for this?

from 0bin.

pjz avatar pjz commented on June 14, 2024

Nope. I eventually gave up and made a virtual host for it.

from 0bin.

sametmax avatar sametmax commented on June 14, 2024

It's about time I work into 0bin again to solve this issue and port it to Python 3. It seems I can't find a good WE to do it. I'm sorry, I'm a real procrastinator sometime.

from 0bin.

ksamuel avatar ksamuel commented on June 14, 2024

Well, new maintainer for 0bin now, so the V2 branch is now python 3 only :)

from 0bin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.