librelist archives

« back to archive

Strange behavior during deployment using wsgi and apache2

Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-14 @ 07:44
Hi,

I am using DigitalOcean for hosting app using wsgi and apache. It works
fine on www.myapp.com while it shows only "Apache2 Ubuntu Default Page" on
myapp.com which means that __init__.py does not get served in case of
myapp.com while it does get served in case of www.myapp.com.

I am puzzled by this - anyone has suggestions/ideas where to look for issue?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Little more detail:
- at first I had only myapp.com which never served content but then I added
www.myapp.com by changing DNS settings at DigitalOcean - I added A record
with www and IP
- my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
- flaskapp.wsgi file is saved in FlaskApp folder
- flaskapp.wsgi has line in it - from MyApp import app as application
- flaskapp.wsgi has line to point to Python3.4 interpreter
- flaskapp.wsgi has line to create path "var/www/FlaskApp"
- FlaskApp.conf file is saved in /etc/apache2/sites-available/
- there are two virtualhost records for myapp.com and www.myapp.com
- both records are identical with the exception of ServerName
- relevant part of virtualhost is below:


WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi

<Directory /var/www/FlaskApp/MyApp/>

Order allow,deny

Allow from all

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Thank you in advance,

Yaroslav

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Cornelius Kölbel
Date:
2014-12-14 @ 08:42
Hi,
 I doubt this being a flask issue.

1. Check your DNS. Does myapp.com resolve to the same IP address like
www.myapp.com?
    If yes, go to 2.

2. Then it is an apache issue. How does the files look in
    /etc/apache2/sites-enabled/
    Are there two files? Please post the contents of the files.
    You might have two files and one providing
        servername www.myapp.com
    and the other
        servername myapp.com

Kind regards
Cornelius


Am 14.12.2014 um 08:44 schrieb Yaroslav Kyrpych:
> Hi,
>
> I am using DigitalOcean for hosting app using wsgi and apache. It
> works fine on www.myapp.com <http://www.myapp.com> while it shows only
> "Apache2 Ubuntu Default Page" on myapp.com <http://myapp.com> which
> means that __init__.py does not get served in case of myapp.com
> <http://myapp.com> while it does get served in case of www.myapp.com
> <http://www.myapp.com>.
>
> I am puzzled by this - anyone has suggestions/ideas where to look for
> issue?
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Little more detail:
> - at first I had only myapp.com <http://myapp.com> which never served
> content but then I added www.myapp.com <http://www.myapp.com> by
> changing DNS settings at DigitalOcean - I added A record with www and IP
> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
> - flaskapp.wsgi file is saved in FlaskApp folder
> - flaskapp.wsgi has line in it - from MyApp import app as application
> - flaskapp.wsgi has line to point to Python3.4 interpreter
> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
> - there are two virtualhost records for myapp.com <http://myapp.com>
> and www.myapp.com <http://www.myapp.com>
> - both records are identical with the exception of ServerName
> - relevant part of virtualhost is below:
>    
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Thank you in advance,
>
> Yaroslav
>
>

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-14 @ 23:55
Cornelius,

1. Yes, they both resolve to the same IP.

2. No, there is just one file - I read somewhere that I can have two
records in one file. I don't think you can have two separate config files?
Please see below content of FlaskApp.conf:

<VirtualHost *:80>

ServerName myapp.com

ServerAdmin admin@myapp.com

WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi

<Directory /var/www/FlaskApp/MyApp/>

Order allow,deny

Allow from all

</Directory>

Alias /static /var/www/FlaskApp/MyApp/static

<Directory /var/www/FlaskApp/MyApp/static/>

Order allow,deny

Allow from all

</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

 <VirtualHost *:80>

ServerName www.myapp.com

ServerAdmin admin@myapp.com

WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi

<Directory /var/www/FlaskApp/MyApp/>

Order allow,deny

Allow from all

</Directory>

Alias /static /var/www/FlaskApp/MyApp/static

<Directory /var/www/FlaskApp/MyApp/static/>

Order allow,deny

Allow from all

</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Thank you,

Yaroslav


On Sun, Dec 14, 2014 at 2:42 AM, Cornelius Kölbel <cornelius@privacyidea.org
> wrote:
>
>  Hi,
>  I doubt this being a flask issue.
>
> 1. Check your DNS. Does myapp.com resolve to the same IP address like
> www.myapp.com?
>     If yes, go to 2.
>
> 2. Then it is an apache issue. How does the files look in
>     /etc/apache2/sites-enabled/
>     Are there two files? Please post the contents of the files.
>     You might have two files and one providing
>         servername www.myapp.com
>     and the other
>         servername myapp.com
>
> Kind regards
> Cornelius
>
>
> Am 14.12.2014 um 08:44 schrieb Yaroslav Kyrpych:
>
>  Hi,
>
>  I am using DigitalOcean for hosting app using wsgi and apache. It works
> fine on www.myapp.com while it shows only "Apache2 Ubuntu Default Page"
> on myapp.com which means that __init__.py does not get served in case of
> myapp.com while it does get served in case of www.myapp.com.
>
>  I am puzzled by this - anyone has suggestions/ideas where to look for
> issue?
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Little more detail:
> - at first I had only myapp.com which never served content but then I
> added www.myapp.com by changing DNS settings at DigitalOcean - I added A
> record with www and IP
> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
> - flaskapp.wsgi file is saved in FlaskApp folder
> - flaskapp.wsgi has line in it - from MyApp import app as application
> - flaskapp.wsgi has line to point to Python3.4 interpreter
> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
> - there are two virtualhost records for myapp.com and www.myapp.com
> - both records are identical with the exception of ServerName
> - relevant part of virtualhost is below:
>
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Thank you in advance,
>
> Yaroslav
>
>
>

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Cornelius Kölbel
Date:
2014-12-15 @ 07:26
Hello Yaroslav,

you can define several hosts in one file.
In your case, you have one apache virtual host, which you want to
respond to different hostnames, which all resolve to the same IP.

You should have only one VirtualHost in the file - unless you are
working with "NamedVirtualHost". But as you want to serve one content,
this is not necessary.

<VirtualHost *:80>
ServerName myapp.com
*ServerAlias www.myapp.com*
....
</VirtualHost>

Should to the trick.

Kind regards
Cornelius

Am 15.12.2014 um 00:55 schrieb Yaroslav Kyrpych:
> Cornelius,
>
> 1. Yes, they both resolve to the same IP.
>
> 2. No, there is just one file - I read somewhere that I can have two
> records in one file. I don't think you can have two separate config files?
> Please see below content of FlaskApp.conf:
>
> <VirtualHost *:80>
>
> ServerName myapp.com <http://myapp.com>
>
> ServerAdmin admin@myapp.com <mailto:admin@myapp.com>
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> Alias /static /var/www/FlaskApp/MyApp/static
>
> <Directory /var/www/FlaskApp/MyApp/static/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> ErrorLog ${APACHE_LOG_DIR}/error.log
>
> LogLevel warn
>
> CustomLog ${APACHE_LOG_DIR}/access.log combined
>
> </VirtualHost>
>
>  
>
> <VirtualHost *:80>
>
> ServerName www.myapp.com <http://www.myapp.com>
>
> ServerAdmin admin@myapp.com <mailto:admin@myapp.com>
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> Alias /static /var/www/FlaskApp/MyApp/static
>
> <Directory /var/www/FlaskApp/MyApp/static/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> ErrorLog ${APACHE_LOG_DIR}/error.log
>
> LogLevel warn
>
> CustomLog ${APACHE_LOG_DIR}/access.log combined
>
> </VirtualHost>
>
>
> Thank you,
>
> Yaroslav
>
>
> On Sun, Dec 14, 2014 at 2:42 AM, Cornelius Kölbel
> <cornelius@privacyidea.org <mailto:cornelius@privacyidea.org>> wrote:
>
>     Hi,
>      I doubt this being a flask issue.
>
>     1. Check your DNS. Does myapp.com <http://myapp.com> resolve to
>     the same IP address like www.myapp.com <http://www.myapp.com>?
>         If yes, go to 2.
>
>     2. Then it is an apache issue. How does the files look in
>         /etc/apache2/sites-enabled/
>         Are there two files? Please post the contents of the files.
>         You might have two files and one providing
>             servername www.myapp.com <http://www.myapp.com>
>         and the other
>             servername myapp.com <http://myapp.com>
>
>     Kind regards
>     Cornelius
>
>
>     Am 14.12.2014 um 08:44 schrieb Yaroslav Kyrpych:
>>     Hi,
>>
>>     I am using DigitalOcean for hosting app using wsgi and apache. It
>>     works fine on www.myapp.com <http://www.myapp.com> while it shows
>>     only "Apache2 Ubuntu Default Page" on myapp.com
>>     <http://myapp.com> which means that __init__.py does not get
>>     served in case of myapp.com <http://myapp.com> while it does get
>>     served in case of www.myapp.com <http://www.myapp.com>.
>>
>>     I am puzzled by this - anyone has suggestions/ideas where to look
>>     for issue?
>>     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>     Little more detail:
>>     - at first I had only myapp.com <http://myapp.com> which never
>>     served content but then I added www.myapp.com
>>     <http://www.myapp.com> by changing DNS settings at DigitalOcean -
>>     I added A record with www and IP
>>     - my folder structure is as follows:
>>     /var/www/FlaskApp/MyApp/__init__.py
>>     - flaskapp.wsgi file is saved in FlaskApp folder
>>     - flaskapp.wsgi has line in it - from MyApp import app as application
>>     - flaskapp.wsgi has line to point to Python3.4 interpreter
>>     - flaskapp.wsgi has line to create path "var/www/FlaskApp"
>>     - FlaskApp.conf file is saved in /etc/apache2/sites-available/
>>     - there are two virtualhost records for myapp.com
>>     <http://myapp.com> and www.myapp.com <http://www.myapp.com>
>>     - both records are identical with the exception of ServerName
>>     - relevant part of virtualhost is below:
>>        
>>
>>     WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>
>>     <Directory /var/www/FlaskApp/MyApp/>
>>
>>     Order allow,deny
>>
>>     Allow from all
>>
>>     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>>     Thank you in advance,
>>
>>     Yaroslav
>>
>>

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-16 @ 03:09
Hi Cornelius,

I fixed conf file to include ServerAlias as you suggested but it still does
not work. I am really puzzled. I appreciate any ideas/suggestions.

Thank you,

Yaroslav

On Mon, Dec 15, 2014 at 1:26 AM, Cornelius Kölbel <cornelius@privacyidea.org
> wrote:
>
>  Hello Yaroslav,
>
> you can define several hosts in one file.
> In your case, you have one apache virtual host, which you want to respond
> to different hostnames, which all resolve to the same IP.
>
> You should have only one VirtualHost in the file - unless you are working
> with "NamedVirtualHost". But as you want to serve one content, this is not
> necessary.
>
> <VirtualHost *:80>
> ServerName myapp.com
> *ServerAlias www.myapp.com <http://www.myapp.com>*
> ....
> </VirtualHost>
>
> Should to the trick.
>
> Kind regards
> Cornelius
>
> Am 15.12.2014 um 00:55 schrieb Yaroslav Kyrpych:
>
>  Cornelius,
>
>  1. Yes, they both resolve to the same IP.
>
>  2. No, there is just one file - I read somewhere that I can have two
> records in one file. I don't think you can have two separate config files?
> Please see below content of FlaskApp.conf:
>
>  <VirtualHost *:80>
>
> ServerName myapp.com
>
> ServerAdmin admin@myapp.com
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> Alias /static /var/www/FlaskApp/MyApp/static
>
> <Directory /var/www/FlaskApp/MyApp/static/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> ErrorLog ${APACHE_LOG_DIR}/error.log
>
> LogLevel warn
>
> CustomLog ${APACHE_LOG_DIR}/access.log combined
>
> </VirtualHost>
>
>  <VirtualHost *:80>
>
> ServerName www.myapp.com
>
> ServerAdmin admin@myapp.com
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> Alias /static /var/www/FlaskApp/MyApp/static
>
> <Directory /var/www/FlaskApp/MyApp/static/>
>
> Order allow,deny
>
> Allow from all
>
> </Directory>
>
> ErrorLog ${APACHE_LOG_DIR}/error.log
>
> LogLevel warn
>
> CustomLog ${APACHE_LOG_DIR}/access.log combined
>
> </VirtualHost>
>
>  Thank you,
>
>  Yaroslav
>
>
> On Sun, Dec 14, 2014 at 2:42 AM, Cornelius Kölbel <
> cornelius@privacyidea.org> wrote:
>>
>>  Hi,
>>  I doubt this being a flask issue.
>>
>> 1. Check your DNS. Does myapp.com resolve to the same IP address like
>> www.myapp.com?
>>     If yes, go to 2.
>>
>> 2. Then it is an apache issue. How does the files look in
>>     /etc/apache2/sites-enabled/
>>     Are there two files? Please post the contents of the files.
>>     You might have two files and one providing
>>         servername www.myapp.com
>>     and the other
>>         servername myapp.com
>>
>> Kind regards
>> Cornelius
>>
>>
>> Am 14.12.2014 um 08:44 schrieb Yaroslav Kyrpych:
>>
>>  Hi,
>>
>>  I am using DigitalOcean for hosting app using wsgi and apache. It works
>> fine on www.myapp.com while it shows only "Apache2 Ubuntu Default Page"
>> on myapp.com which means that __init__.py does not get served in case of
>> myapp.com while it does get served in case of www.myapp.com.
>>
>>  I am puzzled by this - anyone has suggestions/ideas where to look for
>> issue?
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Little more detail:
>> - at first I had only myapp.com which never served content but then I
>> added www.myapp.com by changing DNS settings at DigitalOcean - I added A
>> record with www and IP
>> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
>> - flaskapp.wsgi file is saved in FlaskApp folder
>> - flaskapp.wsgi has line in it - from MyApp import app as application
>> - flaskapp.wsgi has line to point to Python3.4 interpreter
>> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
>> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
>> - there are two virtualhost records for myapp.com and www.myapp.com
>> - both records are identical with the exception of ServerName
>> - relevant part of virtualhost is below:
>>
>>
>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>
>> <Directory /var/www/FlaskApp/MyApp/>
>>
>> Order allow,deny
>>
>> Allow from all
>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>> Thank you in advance,
>>
>> Yaroslav
>>
>>
>>

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-16 @ 06:38
I finally figured out what happened - wanted to share in case someone will
face the same issue. It turns out that Apache installs default config file
during installation, I did not touch it assuming that I did not create it
and therefore there should not be anything working. Well, there was a line
of code that was actually working and overriding settings in my config
file. I modified default file to mimic my actual one. I assume that another
possible solution is to delete default config, but I decided not to do that.

On Mon, Dec 15, 2014 at 9:09 PM, Yaroslav Kyrpych <
yaroslav.kyrpych@gmail.com> wrote:
>
> Hi Cornelius,
>
> I fixed conf file to include ServerAlias as you suggested but it still
> does not work. I am really puzzled. I appreciate any ideas/suggestions.
>
> Thank you,
>
> Yaroslav
>
> On Mon, Dec 15, 2014 at 1:26 AM, Cornelius Kölbel <
> cornelius@privacyidea.org> wrote:
>>
>>  Hello Yaroslav,
>>
>> you can define several hosts in one file.
>> In your case, you have one apache virtual host, which you want to respond
>> to different hostnames, which all resolve to the same IP.
>>
>> You should have only one VirtualHost in the file - unless you are working
>> with "NamedVirtualHost". But as you want to serve one content, this is not
>> necessary.
>>
>> <VirtualHost *:80>
>> ServerName myapp.com
>> *ServerAlias www.myapp.com <http://www.myapp.com>*
>> ....
>> </VirtualHost>
>>
>> Should to the trick.
>>
>> Kind regards
>> Cornelius
>>
>> Am 15.12.2014 um 00:55 schrieb Yaroslav Kyrpych:
>>
>>  Cornelius,
>>
>>  1. Yes, they both resolve to the same IP.
>>
>>  2. No, there is just one file - I read somewhere that I can have two
>> records in one file. I don't think you can have two separate config files?
>> Please see below content of FlaskApp.conf:
>>
>>  <VirtualHost *:80>
>>
>> ServerName myapp.com
>>
>> ServerAdmin admin@myapp.com
>>
>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>
>> <Directory /var/www/FlaskApp/MyApp/>
>>
>> Order allow,deny
>>
>> Allow from all
>>
>> </Directory>
>>
>> Alias /static /var/www/FlaskApp/MyApp/static
>>
>> <Directory /var/www/FlaskApp/MyApp/static/>
>>
>> Order allow,deny
>>
>> Allow from all
>>
>> </Directory>
>>
>> ErrorLog ${APACHE_LOG_DIR}/error.log
>>
>> LogLevel warn
>>
>> CustomLog ${APACHE_LOG_DIR}/access.log combined
>>
>> </VirtualHost>
>>
>>  <VirtualHost *:80>
>>
>> ServerName www.myapp.com
>>
>> ServerAdmin admin@myapp.com
>>
>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>
>> <Directory /var/www/FlaskApp/MyApp/>
>>
>> Order allow,deny
>>
>> Allow from all
>>
>> </Directory>
>>
>> Alias /static /var/www/FlaskApp/MyApp/static
>>
>> <Directory /var/www/FlaskApp/MyApp/static/>
>>
>> Order allow,deny
>>
>> Allow from all
>>
>> </Directory>
>>
>> ErrorLog ${APACHE_LOG_DIR}/error.log
>>
>> LogLevel warn
>>
>> CustomLog ${APACHE_LOG_DIR}/access.log combined
>>
>> </VirtualHost>
>>
>>  Thank you,
>>
>>  Yaroslav
>>
>>
>> On Sun, Dec 14, 2014 at 2:42 AM, Cornelius Kölbel <
>> cornelius@privacyidea.org> wrote:
>>>
>>>  Hi,
>>>  I doubt this being a flask issue.
>>>
>>> 1. Check your DNS. Does myapp.com resolve to the same IP address like
>>> www.myapp.com?
>>>     If yes, go to 2.
>>>
>>> 2. Then it is an apache issue. How does the files look in
>>>     /etc/apache2/sites-enabled/
>>>     Are there two files? Please post the contents of the files.
>>>     You might have two files and one providing
>>>         servername www.myapp.com
>>>     and the other
>>>         servername myapp.com
>>>
>>> Kind regards
>>> Cornelius
>>>
>>>
>>> Am 14.12.2014 um 08:44 schrieb Yaroslav Kyrpych:
>>>
>>>  Hi,
>>>
>>>  I am using DigitalOcean for hosting app using wsgi and apache. It
>>> works fine on www.myapp.com while it shows only "Apache2 Ubuntu Default
>>> Page" on myapp.com which means that __init__.py does not get served in
>>> case of myapp.com while it does get served in case of www.myapp.com.
>>>
>>>  I am puzzled by this - anyone has suggestions/ideas where to look for
>>> issue?
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> Little more detail:
>>> - at first I had only myapp.com which never served content but then I
>>> added www.myapp.com by changing DNS settings at DigitalOcean - I added
>>> A record with www and IP
>>> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
>>> - flaskapp.wsgi file is saved in FlaskApp folder
>>> - flaskapp.wsgi has line in it - from MyApp import app as application
>>> - flaskapp.wsgi has line to point to Python3.4 interpreter
>>> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
>>> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
>>> - there are two virtualhost records for myapp.com and www.myapp.com
>>> - both records are identical with the exception of ServerName
>>> - relevant part of virtualhost is below:
>>>
>>>
>>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>>
>>> <Directory /var/www/FlaskApp/MyApp/>
>>>
>>> Order allow,deny
>>>
>>> Allow from all
>>>
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>
>>> Thank you in advance,
>>>
>>> Yaroslav
>>>
>>>
>>>

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Matthias Urlichs
Date:
2014-12-22 @ 10:13
Hi,

Yaroslav Kyrpych:
> It turns out that Apache installs default config file during
> installation, I did not touch it assuming that I did not create it and
> therefore there should not be anything working.

Yeah I frequently run into this, too. Seems that Apache sometimes thinks
that the defaults file takes precedence over a specific host.
I haven't yet figured out how to trigger that condition. :-/

-- 
-- Matthias Urlichs

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-15 @ 14:08
Thank you!

> On Dec 15, 2014, at 1:26, "Cornelius Kölbel" <cornelius@privacyidea.org> wrote:
> 
> Hello Yaroslav,
> 
> you can define several hosts in one file.
> In your case, you have one apache virtual host, which you want to 
respond to different hostnames, which all resolve to the same IP.
> 
> You should have only one VirtualHost in the file - unless you are 
working with "NamedVirtualHost". But as you want to serve one content, 
this is not necessary.
> 
> <VirtualHost *:80>
> ServerName myapp.com
> ServerAlias www.myapp.com
> ....
> </VirtualHost>
> 
> Should to the trick.
> 
> Kind regards
> Cornelius
> 
>> Am 15.12.2014 um 00:55 schrieb Yaroslav Kyrpych:
>> Cornelius,
>> 
>> 1. Yes, they both resolve to the same IP.
>> 
>> 2. No, there is just one file - I read somewhere that I can have two 
records in one file. I don't think you can have two separate config files?
>> Please see below content of FlaskApp.conf:
>> 
>> <VirtualHost *:80>
>> 
>> ServerName myapp.com
>> 
>> ServerAdmin admin@myapp.com
>> 
>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>> 
>> <Directory /var/www/FlaskApp/MyApp/>
>> 
>> Order allow,deny
>> 
>> Allow from all
>> 
>> </Directory>
>> 
>> Alias /static /var/www/FlaskApp/MyApp/static
>> 
>> <Directory /var/www/FlaskApp/MyApp/static/>
>> 
>> Order allow,deny
>> 
>> Allow from all
>> 
>> </Directory>
>> 
>> ErrorLog ${APACHE_LOG_DIR}/error.log
>> 
>> LogLevel warn
>> 
>> CustomLog ${APACHE_LOG_DIR}/access.log combined
>> 
>> </VirtualHost>
>> 
>>  
>> 
>> <VirtualHost *:80>
>> 
>> ServerName www.myapp.com
>> 
>> ServerAdmin admin@myapp.com
>> 
>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>> 
>> <Directory /var/www/FlaskApp/MyApp/>
>> 
>> Order allow,deny
>> 
>> Allow from all
>> 
>> </Directory>
>> 
>> Alias /static /var/www/FlaskApp/MyApp/static
>> 
>> <Directory /var/www/FlaskApp/MyApp/static/>
>> 
>> Order allow,deny
>> 
>> Allow from all
>> 
>> </Directory>
>> 
>> ErrorLog ${APACHE_LOG_DIR}/error.log
>> 
>> LogLevel warn
>> 
>> CustomLog ${APACHE_LOG_DIR}/access.log combined
>> 
>> </VirtualHost>
>> 
>> 
>> Thank you,
>> 
>> Yaroslav
>> 
>> 
>> On Sun, Dec 14, 2014 at 2:42 AM,           Cornelius Kölbel 
<cornelius@privacyidea.org> wrote:
>>> 
>>> Hi,
>>>  I doubt this being a flask issue.
>>> 
>>> 1. Check your DNS. Does myapp.com resolve to the same IP address like 
www.myapp.com?
>>>     If yes, go to 2.
>>> 
>>> 2. Then it is an apache issue. How does the files look in 
>>>     /etc/apache2/sites-enabled/
>>>     Are there two files? Please post the contents of the files.
>>>     You might have two files and one providing
>>>         servername www.myapp.com
>>>     and the other
>>>         servername myapp.com
>>> 
>>> Kind regards
>>> Cornelius
>>> 
>>> 
>>> Am 14.12.2014 um 08:44 schrieb Yaroslav Kyrpych:
>>>> Hi,
>>>> 
>>>> I am using DigitalOcean for hosting app using wsgi and apache. It 
works fine on www.myapp.com while it shows only "Apache2 Ubuntu Default 
Page" on myapp.com which means that __init__.py does not get served in 
case of myapp.com while it does get served in case of www.myapp.com.
>>>> 
>>>> I am puzzled by this - anyone has suggestions/ideas where to look for issue?
>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> Little more detail:
>>>> - at first I had only myapp.com which never served content but then I
added www.myapp.com by changing DNS settings at DigitalOcean - I added A 
record with www and IP
>>>> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
>>>> - flaskapp.wsgi file is saved in FlaskApp folder
>>>> - flaskapp.wsgi has line in it - from MyApp import app as application
>>>> - flaskapp.wsgi has line to point to Python3.4 interpreter
>>>> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
>>>> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
>>>> - there are two virtualhost records for myapp.com and www.myapp.com
>>>> - both records are identical with the exception of ServerName
>>>> - relevant part of virtualhost is below:
>>>>    
>>>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>>> 
>>>> <Directory /var/www/FlaskApp/MyApp/>
>>>> 
>>>> Order allow,deny
>>>> 
>>>> Allow from all
>>>> 
>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> 
>>>> Thank you in advance,
>>>> 
>>>> Yaroslav

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Ioannis Pinakoulakis
Date:
2014-12-14 @ 10:12
HI, 

instead of an A record for www.myapp.com <http://www.myapp.com/> add a 
CNAME record. You have to dig in to your records in DNS (there is a 
magnifying glass that you need to press).

It seems very likely that it’s not a flask problem, but I’m not sure that 
it will help.

/Ioannis


> On 14 Dec 2014, at 08:44, Yaroslav Kyrpych <yaroslav.kyrpych@gmail.com> wrote:
> 
> Hi,
> 
> I am using DigitalOcean for hosting app using wsgi and apache. It works 
fine on www.myapp.com <http://www.myapp.com/> while it shows only "Apache2
Ubuntu Default Page" on myapp.com <http://myapp.com/> which means that 
__init__.py does not get served in case of myapp.com <http://myapp.com/> 
while it does get served in case of www.myapp.com <http://www.myapp.com/>.
> 
> I am puzzled by this - anyone has suggestions/ideas where to look for issue?
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Little more detail:
> - at first I had only myapp.com <http://myapp.com/> which never served 
content but then I added www.myapp.com <http://www.myapp.com/> by changing
DNS settings at DigitalOcean - I added A record with www and IP
> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
> - flaskapp.wsgi file is saved in FlaskApp folder
> - flaskapp.wsgi has line in it - from MyApp import app as application
> - flaskapp.wsgi has line to point to Python3.4 interpreter
> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
> - there are two virtualhost records for myapp.com <http://myapp.com/> 
and www.myapp.com <http://www.myapp.com/>
> - both records are identical with the exception of ServerName
> - relevant part of virtualhost is below:
>    
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
> 
> <Directory /var/www/FlaskApp/MyApp/>
> 
> Order allow,deny
> 
> Allow from all
> 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> Thank you in advance,
> 
> Yaroslav
> 
> 
> 

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-15 @ 00:03
Hi,

I added A record in DNS after talking to DigitalOcean helpdesk - they
mentioned that either (A or CNAME) should work. I am not expert in this, so
I just used A record. After that my www started to get served, before it
did not work at all.

It seems to me that the problem is related to Apache but I cannot figure it
out.

Best,

Yaroslav

On Sun, Dec 14, 2014 at 4:12 AM, Ioannis Pinakoulakis <giannis.pin@gmail.com
> wrote:
>
> HI,
>
> instead of an A record for www.myapp.com add a CNAME record. You have to
> dig in to your records in DNS (there is a magnifying glass that you need to
> press).
>
> It seems very likely that it’s not a flask problem, but I’m not sure that
> it will help.
>
> /Ioannis
>
>
> On 14 Dec 2014, at 08:44, Yaroslav Kyrpych <yaroslav.kyrpych@gmail.com>
> wrote:
>
> Hi,
>
> I am using DigitalOcean for hosting app using wsgi and apache. It works
> fine on www.myapp.com while it shows only "Apache2 Ubuntu Default Page"
> on myapp.com which means that __init__.py does not get served in case of
> myapp.com while it does get served in case of www.myapp.com.
>
> I am puzzled by this - anyone has suggestions/ideas where to look for
> issue?
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Little more detail:
> - at first I had only myapp.com which never served content but then I
> added www.myapp.com by changin g DNS settings at DigitalOcean - I added A
> record with www and IP
> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
> - flaskapp.wsgi file is saved in FlaskApp folder
> - flaskapp.wsgi has line in it - from MyApp import app as application
> - flaskapp.wsgi has line to point to Python3.4 interpreter
> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
> - there are two virtualhost records for myapp.com and www.myapp.com
> - both records are identical with the exception of ServerName
> - relevant part of virtualhost is below:
>
>
> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>
> <Directory /var/www/FlaskApp/MyApp/>
>
> Order allow,deny
>
> Allow from all
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Thank you in advance,
>
> Yaroslav
>
>
>
>

Re: [flask] Strange behavior during deployment using wsgi and apache2

From:
Yaroslav Kyrpych
Date:
2014-12-15 @ 00:11
Follow-up on the last post:
I have two A records now on DO in addition to 3 NS records:
A   @       IP address
A   www   IP address

Both IPs are the same.

On Sun, Dec 14, 2014 at 6:03 PM, Yaroslav Kyrpych <
yaroslav.kyrpych@gmail.com> wrote:
>
> Hi,
>
> I added A record in DNS after talking to DigitalOcean helpdesk - they
> mentioned that either (A or CNAME) should work. I am not expert in this, so
> I just used A record. After that my www started to get served, before it
> did not work at all.
>
> It seems to me that the problem is related to Apache but I cannot figure
> it out.
>
> Best,
>
> Yaroslav
>
> On Sun, Dec 14, 2014 at 4:12 AM, Ioannis Pinakoulakis <
> giannis.pin@gmail.com> wrote:
>>
>> HI,
>>
>> instead of an A record for www.myapp.com add a CNAME record. You have to
>> dig in to your records in DNS (there is a magnifying glass that you need to
>> press).
>>
>> It seems very likely that it’s not a flask problem, but I’m not sure that
>> it will help.
>>
>> /Ioannis
>>
>>
>> On 14 Dec 2014, at 08:44, Yaroslav Kyrpych <yaroslav.kyrpych@gmail.com>
>> wrote:
>>
>> Hi,
>>
>> I am using DigitalOcean for hosting app using wsgi and apache. It works
>> fine on www.myapp.com while it shows only "Apache2 Ubuntu Default Page"
>> on myapp.com which means that __init__.py does not get served in case of
>> myapp.com while it does get served in case of www.myapp.com.
>>
>> I am puzzled by this - anyone has suggestions/ideas where to look for
>> issue?
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Little more detail:
>> - at first I had only myapp.com which never served content but then I
>> added www.myapp.com by changin g DNS settings at DigitalOcean - I added
>> A record with www and IP
>> - my folder structure is as follows: /var/www/FlaskApp/MyApp/__init__.py
>> - flaskapp.wsgi file is saved in FlaskApp folder
>> - flaskapp.wsgi has line in it - from MyApp import app as application
>> - flaskapp.wsgi has line to point to Python3.4 interpreter
>> - flaskapp.wsgi has line to create path "var/www/FlaskApp"
>> - FlaskApp.conf file is saved in /etc/apache2/sites-available/
>> - there are two virtualhost records for myapp.com and www.myapp.com
>> - both records are identical with the exception of ServerName
>> - relevant part of virtualhost is below:
>>
>>
>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
>>
>> <Directory /var/www/FlaskApp/MyApp/>
>>
>> Order allow,deny
>>
>> Allow from all
>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>> Thank you in advance,
>>
>> Yaroslav
>>
>>
>>
>>