[web2py] help with apache

2011-04-28 Thread Massimo Di Pierro
I am looking for an apache module to do the following:

Let's say I have web2py running under http://example.com behind apache
(mod_wsgi, mod_proxy, or other does not matter) and apache is also
serving static files from a non-web2py-related folder.

I want to restrict access to some of the static files depending on
whether the user has logged into web2py or not.

There are ways to do it using mod_auth_tkt, mod_auth_pubtkt, etc. but
they are all more complex than need to be.

I would like an apache module that works like this:

- when a user visits the url for one of the static files
- the web server makes an http request (not a redirect) to a URL I
specify in the configuration (the url of a web2py page)
- passes the cookies along with the request
- if the request succeeds, the web server returns the original
requested file
- if the request fails with not-authorized, the web server returns not
authorized
- if the request redirects, the web server also redirects (assuming to
a login page)
- the body of the response of the background request is ignored and
irrelevant.

Is there an apache module to do this? I cannot find one and yet it
seems so obvious.

Massimo

P.S. I know I can do this with mod_wsgi by calling a wsgi script but I
want to do it with an http request instead.




[web2py] help with apache

2012-08-31 Thread Massimo Di Pierro
My web server started exhibiting a strange behavior:

$ /etc/init.d/apache stop
[ok]
$ /etc/init.d/apache start
 * Starting web server apache2 
 
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAIL]
$ netstat -tulpn| grep :80
(No info could be read for "-p": geteuid()=1000 but you should be root.)
tcp6   0  0 :::80   :::*LISTEN 

The only way to restart it is by rebooting. Any idea what may cause this? I 
have not seen before and did not change the server config in a while.



-- 





Re: [web2py] help with apache

2011-04-28 Thread Michele Comitini
I am guessing wild here, never done.

mod_proxy + mod_rewrite

Rewrite all urls requesting static content to point to a url where
web2py responds with a url pointing to localhost.
Correct url content is fetched by proxy from apache itself on
localhost (there you have  that cannot be reached by
outside)
and served back to the user.

mic


2011/4/28 Massimo Di Pierro :
> I am looking for an apache module to do the following:
>
> Let's say I have web2py running under http://example.com behind apache
> (mod_wsgi, mod_proxy, or other does not matter) and apache is also
> serving static files from a non-web2py-related folder.
>
> I want to restrict access to some of the static files depending on
> whether the user has logged into web2py or not.
>
> There are ways to do it using mod_auth_tkt, mod_auth_pubtkt, etc. but
> they are all more complex than need to be.
>
> I would like an apache module that works like this:
>
> - when a user visits the url for one of the static files
> - the web server makes an http request (not a redirect) to a URL I
> specify in the configuration (the url of a web2py page)
> - passes the cookies along with the request
> - if the request succeeds, the web server returns the original
> requested file
> - if the request fails with not-authorized, the web server returns not
> authorized
> - if the request redirects, the web server also redirects (assuming to
> a login page)
> - the body of the response of the background request is ignored and
> irrelevant.
>
> Is there an apache module to do this? I cannot find one and yet it
> seems so obvious.
>
> Massimo
>
> P.S. I know I can do this with mod_wsgi by calling a wsgi script but I
> want to do it with an http request instead.
>
>
>


Re: [web2py] help with apache

2012-08-31 Thread Bruno Rocha
There is something here: http://ubuntuforums.org/showthread.php?t=1636667

On Fri, Aug 31, 2012 at 7:02 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Address already in use: make_sock: could not bind to address [::]:80

-- 





Re: [web2py] help with apache

2012-08-31 Thread Massimo Di Pierro
That helps. Somehow my screen was not large enough and I did not see the 
PID.

mdipierro@www:~$ sudo /etc/init.d/apache2 stop
[sudo] password for mdipierro: 
 * Stopping web server apache2 
 [ OK ] 
mdipierro@www:~$ sudo /etc/init.d/apache2 start
 * Starting web server apache2 

(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

[fail]
mdipierro@www:~$ sudo netstat -ltnp | grep ':80'
tcp6   0  0 :::80   :::*LISTEN 
 3874/uuidd  
mdipierro@www:~$ sudo kill -9 3874
mdipierro@www:~$ sudo /etc/init.d/apache2 start
 * Starting web server apache2 
 [ OK ]

yet I do not understand what this uuidd keep the port locked.

This is the only thing I found on the subject:

https://groups.google.com/group/ec2ubuntu/browse_thread/thread/74af88ecd4e57b3a

and no answer.



On Friday, 31 August 2012 17:15:49 UTC-5, rochacbruno wrote:
>
> There is something here: http://ubuntuforums.org/showthread.php?t=1636667
>
> On Fri, Aug 31, 2012 at 7:02 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> Address already in use: make_sock: could not bind to address [::]:80
>
>
>
>

-- 





Re: [web2py] help with apache

2012-08-31 Thread Cliff Kachinske
Maybe you have an orphan process?

http://www.geekride.com/orphan-zombie-process/

On Friday, August 31, 2012 7:10:25 PM UTC-4, Massimo Di Pierro wrote:
>
> That helps. Somehow my screen was not large enough and I did not see the 
> PID.
>
> mdipierro@www:~$ sudo /etc/init.d/apache2 stop
> [sudo] password for mdipierro: 
>  * Stopping web server apache2 
>  [ OK ] 
> mdipierro@www:~$ sudo /etc/init.d/apache2 start
>  * Starting web server apache2 
> 
> (98)Address already in use: make_sock: could not bind to address [::]:80
> (98)Address already in use: make_sock: could not bind to address 
> 0.0.0.0:80
> no listening sockets available, shutting down
> Unable to open logs
>   
>   [fail]
> mdipierro@www:~$ sudo netstat -ltnp | grep ':80'
> tcp6   0  0 :::80   :::*LISTEN 
>  3874/uuidd  
> mdipierro@www:~$ sudo kill -9 3874
> mdipierro@www:~$ sudo /etc/init.d/apache2 start
>  * Starting web server apache2 
>  [ OK ]
>
> yet I do not understand what this uuidd keep the port locked.
>
> This is the only thing I found on the subject:
>
>
> https://groups.google.com/group/ec2ubuntu/browse_thread/thread/74af88ecd4e57b3a
>
> and no answer.
>
>
>
> On Friday, 31 August 2012 17:15:49 UTC-5, rochacbruno wrote:
>>
>> There is something here: http://ubuntuforums.org/showthread.php?t=1636667
>>
>> On Fri, Aug 31, 2012 at 7:02 PM, Massimo Di Pierro > > wrote:
>>
>>> Address already in use: make_sock: could not bind to address [::]:80
>>
>>
>>
>>

-- 





Re: [web2py] help with apache

2012-08-31 Thread Marin Pranjić
I have the same problem, but starting web2py with WingIDE debugger
(rocket). It happens on ubuntu but not on windows (I do not use windows
much so maybe I didn't notice yet). I change ~5 ports in one day.

And this wasn't happening before.

On Sep 1, 2012 12:02 AM, "Massimo Di Pierro" 
wrote:

My web server started exhibiting a strange behavior:

$ /etc/init.d/apache stop
[ok]
$ /etc/init.d/apache start
 * Starting web server apache2

(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAIL]
$ netstat -tulpn| grep :80
(No info could be read for "-p": geteuid()=1000 but you should be root.)
tcp6   0  0 :::80   :::*LISTEN

The only way to restart it is by rebooting. Any idea what may cause this? I
have not seen before and did not change the server config in a while.



 --

-- 





Re: [web2py] help with apache

2012-09-01 Thread Massimo Di Pierro
Can you try figur out which web2py change introduced the problem?

On Saturday, 1 September 2012 00:12:57 UTC-5, Marin Pranjić wrote:
>
> I have the same problem, but starting web2py with WingIDE debugger 
> (rocket). It happens on ubuntu but not on windows (I do not use windows 
> much so maybe I didn't notice yet). I change ~5 ports in one day.
>
> And this wasn't happening before.
>
> On Sep 1, 2012 12:02 AM, "Massimo Di Pierro" 
> > 
> wrote:
>
> My web server started exhibiting a strange behavior:
>
> $ /etc/init.d/apache stop
> [ok]
> $ /etc/init.d/apache start
>  * Starting web server apache2 
>  
> (98)Address already in use: make_sock: could not bind to address [::]:80
> (98)Address already in use: make_sock: could not bind to address 
> 0.0.0.0:80
> no listening sockets available, shutting down
> Unable to open logs
> [FAIL]
> $ netstat -tulpn| grep :80
> (No info could be read for "-p": geteuid()=1000 but you should be root.)
> tcp6   0  0 :::80   :::*LISTEN 
>
> The only way to restart it is by rebooting. Any idea what may cause this? 
> I have not seen before and did not change the server config in a while.
>
>
>
>  -- 
>  
>  
>  
>
>

-- 





Re: [web2py] help with apache

2012-09-01 Thread Niphlod
I think the problem you are facing is the one described here Massimo: 
https://groups.google.com/forum/?fromgroups=#!topic/django-users/yDp6oSuxER0 

Never happened to me, but I use nginx+uwsgi since forever, I'm not very 
well versed in apache...

-- 





Re: [web2py] help with apache

2012-09-01 Thread Marin Pranjić
Sure. First I need to find out what triggers it but that should be easy
part.


On Sat, Sep 1, 2012 at 2:13 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Can you try figur out which web2py change introduced the problem?
>
>
> On Saturday, 1 September 2012 00:12:57 UTC-5, Marin Pranjić wrote:
>
>> I have the same problem, but starting web2py with WingIDE debugger
>> (rocket). It happens on ubuntu but not on windows (I do not use windows
>> much so maybe I didn't notice yet). I change ~5 ports in one day.
>>
>> And this wasn't happening before.
>>
>> On Sep 1, 2012 12:02 AM, "Massimo Di Pierro" 
>> wrote:
>>
>> My web server started exhibiting a strange behavior:
>>
>> $ /etc/init.d/apache stop
>> [ok]
>> $ /etc/init.d/apache start
>>  * Starting web server apache2
>>
>> (98)Address already in use: make_sock: could not bind to address [::]:80
>> (98)Address already in use: make_sock: could not bind to address
>> 0.0.0.0:80
>> no listening sockets available, shutting down
>> Unable to open logs
>> [FAIL]
>> $ netstat -tulpn| grep :80
>> (No info could be read for "-p": geteuid()=1000 but you should be root.)
>> tcp6   0  0 :::80   :::*
>>  LISTEN
>>
>> The only way to restart it is by rebooting. Any idea what may cause this?
>> I have not seen before and did not change the server config in a while.
>>
>>
>>
>>  --
>>
>>
>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] help with apache

2012-09-01 Thread Marin Pranjić
Maybe not so easy... I only got it twice and I have no idea what exactly
did I do.
This will take a while... It is hard to reproduce.

On Sat, Sep 1, 2012 at 2:25 PM, Marin Pranjić wrote:

> Sure. First I need to find out what triggers it but that should be easy
> part.
>
>
>
> On Sat, Sep 1, 2012 at 2:13 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Can you try figur out which web2py change introduced the problem?
>>
>>
>> On Saturday, 1 September 2012 00:12:57 UTC-5, Marin Pranjić wrote:
>>
>>> I have the same problem, but starting web2py with WingIDE debugger
>>> (rocket). It happens on ubuntu but not on windows (I do not use windows
>>> much so maybe I didn't notice yet). I change ~5 ports in one day.
>>>
>>> And this wasn't happening before.
>>>
>>> On Sep 1, 2012 12:02 AM, "Massimo Di Pierro" 
>>> wrote:
>>>
>>> My web server started exhibiting a strange behavior:
>>>
>>> $ /etc/init.d/apache stop
>>> [ok]
>>> $ /etc/init.d/apache start
>>>  * Starting web server apache2
>>>
>>> (98)Address already in use: make_sock: could not bind to address [::]:80
>>> (98)Address already in use: make_sock: could not bind to address
>>> 0.0.0.0:80
>>> no listening sockets available, shutting down
>>> Unable to open logs
>>>  [FAIL]
>>> $ netstat -tulpn| grep :80
>>> (No info could be read for "-p": geteuid()=1000 but you should be root.)
>>> tcp6   0  0 :::80   :::*
>>>  LISTEN
>>>
>>> The only way to restart it is by rebooting. Any idea what may cause
>>> this? I have not seen before and did not change the server config in a
>>> while.
>>>
>>>
>>>
>>>  --
>>>
>>>
>>>
>>>
>>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] help with apache

2012-09-01 Thread Massimo Di Pierro
On my machine it is 100% of the times. Strange. what calls uuidd? Perhaps 
the new CRYPT logic which calls web2py_uuid()

On Saturday, 1 September 2012 09:47:48 UTC-5, Marin Pranjić wrote:
>
> Maybe not so easy... I only got it twice and I have no idea what exactly 
> did I do.
> This will take a while... It is hard to reproduce.
>
> On Sat, Sep 1, 2012 at 2:25 PM, Marin Pranjić 
> 
> > wrote:
>
>> Sure. First I need to find out what triggers it but that should be easy 
>> part.
>>
>>
>>
>> On Sat, Sep 1, 2012 at 2:13 PM, Massimo Di Pierro 
>> 
>> > wrote:
>>
>>> Can you try figur out which web2py change introduced the problem?
>>>
>>>
>>> On Saturday, 1 September 2012 00:12:57 UTC-5, Marin Pranjić wrote:
>>>
 I have the same problem, but starting web2py with WingIDE debugger 
 (rocket). It happens on ubuntu but not on windows (I do not use windows 
 much so maybe I didn't notice yet). I change ~5 ports in one day.

 And this wasn't happening before.

 On Sep 1, 2012 12:02 AM, "Massimo Di Pierro"  
 wrote:

 My web server started exhibiting a strange behavior:

 $ /etc/init.d/apache stop
 [ok]
 $ /etc/init.d/apache start
  * Starting web server apache2 
  
 (98)Address already in use: make_sock: could not bind to address [::]:80
 (98)Address already in use: make_sock: could not bind to address 
 0.0.0.0:80
 no listening sockets available, shutting down
 Unable to open logs
  [FAIL]
 $ netstat -tulpn| grep :80
 (No info could be read for "-p": geteuid()=1000 but you should be root.)
 tcp6   0  0 :::80   :::*   
  LISTEN 

 The only way to restart it is by rebooting. Any idea what may cause 
 this? I have not seen before and did not change the server config in a 
 while.



  -- 
  
  
  

  -- 
>>>  
>>>  
>>>  
>>>
>>
>>
>

-- 





Re: [web2py] help with apache

2012-09-01 Thread Niphlod
uhm, someone did not read carefully ^_^  I'll post here the relevant 
post from the thread before, I think the user in question (pcastellazzi) 
nailed it.

The python uuid library use libuuid from e2fsprogs (at least in 
> ubuntu). This particular uuid library spanws a daemon called uuidd to 
> help with concurrent uuid generation. As far as i know the only way to 
> disable this behaviour is to compile libuuid with --disable-uuidd 
> option. 
>
> When you run ./manage.py runserver the first time, libuuid launch 
> uuidd with fork(2). This cause uuidd to inherit all open file 
> descriptors from the parent process. In this case the parent process 
> is the python interpreter running manage.py and the open file 
> descriptors are among other things the open tcp connections. After 
> that manage.py will (probably) hang whiel serving a request, and if it 
> is restarted by hand or by changing a file in your application it will 
> keep saying port already in use until you kill uuidd. 
>
> The most simple workaround is to launch uuidd without parameters. This 
> will make the daemon start without open tcp ports and the library will 
> not try to run uuidd by it self, then do your normal django 
> development stuff and when you are done you can kill uuidd with uuidd - 


-- 





Re: [web2py] help with apache

2012-09-01 Thread Massimo Di Pierro
Thanks. Yes I missed it. So we need to start uuidd at os startup.

On Saturday, 1 September 2012 13:53:36 UTC-5, Niphlod wrote:
>
> uhm, someone did not read carefully ^_^  I'll post here the relevant 
> post from the thread before, I think the user in question (pcastellazzi) 
> nailed it.
>
> The python uuid library use libuuid from e2fsprogs (at least in 
>> ubuntu). This particular uuid library spanws a daemon called uuidd to 
>> help with concurrent uuid generation. As far as i know the only way to 
>> disable this behaviour is to compile libuuid with --disable-uuidd 
>> option. 
>>
>> When you run ./manage.py runserver the first time, libuuid launch 
>> uuidd with fork(2). This cause uuidd to inherit all open file 
>> descriptors from the parent process. In this case the parent process 
>> is the python interpreter running manage.py and the open file 
>> descriptors are among other things the open tcp connections. After 
>> that manage.py will (probably) hang whiel serving a request, and if it 
>> is restarted by hand or by changing a file in your application it will 
>> keep saying port already in use until you kill uuidd. 
>>
>> The most simple workaround is to launch uuidd without parameters. This 
>> will make the daemon start without open tcp ports and the library will 
>> not try to run uuidd by it self, then do your normal django 
>> development stuff and when you are done you can kill uuidd with uuidd - 
>
>
>

-- 





Re: [web2py] help with apache

2012-09-03 Thread Bruno Rocha
I guess it can help you to discover the problems:
http://nicolargo.github.com/glances/

(I would like to have a web-socket version of that app)

--