Trouble accessing static files via url in browser

9 views
Skip to first unread message

Bob Floyd

unread,
Dec 22, 2022, 5:27:32 PM12/22/22
to modwsgi
I put the google search HTML file (for ownership verification) in static/content:

~/WWWsiteServer/static/content$ ls -l
total 244
-rw-rw-r-- 1 nuvroot nuvroot 21748 Dec  6 23:53 BSIM-5-Stage-Inverter.JPG
-rw-rw-r-- 1 nuvroot nuvroot 89457 Dec  6 23:53 Lease.pdf
-rw-rw-r-- 1 nuvroot nuvroot  1078 Dec  6 23:53 NuV2.ico
-rw-rw-r-- 1 nuvroot nuvroot   772 Dec  6 23:53 PDF_32.png
-rw-rw-r-- 1 nuvroot nuvroot 27452 Dec  6 23:53 SecureLeaseSm.JPG
-rw-rw-r-- 1 nuvroot nuvroot  8767 Dec  6 23:53 TrademarkSmall.JPG
-rw-rw-r-- 1 nuvroot nuvroot 77494 Dec  6 23:53 UIDialog.bmp
-rw-rw-r-- 1 nuvroot nuvroot  1078 Dec  9 19:19 favicon.ico
-r--r--r-- 1 nuvroot root       53 Dec 22 01:06 google6821620603f54cd0.html

In my browser I enter https://www.nuv2.com/google6821620603f54cd0.html as recommended by google to test for access to the file and get 404 error.

If you navigate to nuv2.com, the other files in content are properly loaded, although attempting to access any of them using a url in the browser also gives 404.

In the Apache 000-default.conf file I'm using Alias as recommended in the modwsgi docs:
# Remap URL's for static files to where they actually are
    Alias /BSIM-5-Stage-Inverter.JPG /home/nuvroot/WWWsiteServer/static/content/BSIM-5-Stage-Inverter.JPG
    Alias /Lease.pdf   /home/nuvroot/WWWsiteServer/static/content/Lease.pdf
    Alias /NuV2.ico   /home/nuvroot/WWWsiteServer/static/content/NuV2.ico
    Alias /favicon.ico   /home/nuvroot/WWWsiteServer/static/content/favicon.ico
    Alias /PDF_32.png /home/nuvroot/WWWsiteServer/static/content/PDF_32.png
    Alias /SecureLeaseSm.JPG /home/nuvroot/WWWsiteServer/static/content/SecureLeaseSm.JPG
    Alias /TrademarkSmall.JPG /home/nuvroot/WWWsiteServer/static/content/TrademarkSmall.JPG
    Alias /UIDialog.bmp /home/nuvroot/WWWsiteServer/static/content/UIDialog.bmp
    # For google search ownership verification
    Alias /google6821620603f54cd0.html /home/google6821620603f54cd0.html

Any suggestions how I can get access to the google html file from the url? It's probably something simple but I've tried a ton of things without success.

Thanks

Graham Dumpleton

unread,
Dec 22, 2022, 5:31:19 PM12/22/22
to mod...@googlegroups.com
You use "/home/google6821620603f54cd0.html" as the target of the URL path where it should be:

    Alias /google6821620603f54cd0.html /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html

based on what directory you said it was in.

If that still doesn't work then the issue may be that the Apache user doesn't have access to anything under the home directory. So it still getting access error what do you get for:

    ls -lasd /home/nuvroot

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/d69e7b2d-bf4f-417c-847e-0a66bd821d62n%40googlegroups.com.

Bob Floyd

unread,
Dec 22, 2022, 8:45:54 PM12/22/22
to modwsgi
Hi Graham,

$ ls -lasd /home/nuvroot
4 drwxr-xr-x 6 nuvroot nuvroot 4096 Dec 22 15:54 /home/nuvroot

What I tried didn't work, however I'm also bit confused about your use of /home/google6821620603f54cd0.html on the Alias line. As that is the target should the google file also be located there? I don't have access above nuvroot!

Here is the VirtualHost ( I also copied the google file to /home/nuvroot):

# Highest priority
<VirtualHost *:7080>
    
    ServerName www.nuv2.com

    ServerAdmin webmaster@localhost

    DocumentRoot /home/nuvroot/WWWsiteServer

    <Directory /home/nuvroot/WWWsiteServer>
        Require all granted
    </Directory>

     WSGIDaemonProcess nuv2.com python-home=/usr/local/venvs/WWWsiteServer
    WSGIProcessGroup nuv2.com

    WSGIApplicationGroup %{GLOBAL}

       WSGIScriptAlias / /var/www/wsgi/WWWsiteServer.wsgi

    <Directory /var/www/wsgi>
        Require all granted
    </Directory>


      Alias /BSIM-5-Stage-Inverter.JPG /home/nuvroot/WWWsiteServer/static/content/BSIM-5-Stage-Inverter.JPG
    Alias /Lease.pdf   /home/nuvroot/WWWsiteServer/static/content/Lease.pdf
    Alias /NuV2.ico   /home/nuvroot/WWWsiteServer/static/content/NuV2.ico
    Alias /favicon.ico   /home/nuvroot/WWWsiteServer/static/content/favicon.ico
    Alias /PDF_32.png /home/nuvroot/WWWsiteServer/static/content/PDF_32.png
    Alias /SecureLeaseSm.JPG /home/nuvroot/WWWsiteServer/static/content/SecureLeaseSm.JPG
    Alias /TrademarkSmall.JPG /home/nuvroot/WWWsiteServer/static/content/TrademarkSmall.JPG
    Alias /UIDialog.bmp /home/nuvroot/WWWsiteServer/static/content/UIDialog.bmp
    # For google search ownership verification
    Alias /google6821620603f54cd0.html /home/nuvroot/google6821620603f54cd0.html
# I also tried
#Alias /google6821620603f54cd0.html /home/google6821620603f54cd0.html

        ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

  </VirtualHost>

Thanks,
Bob

Graham Dumpleton

unread,
Dec 22, 2022, 8:51:30 PM12/22/22
to mod...@googlegroups.com
Did you try with:

    Alias /google6821620603f54cd0.html /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html

or not?

I wasn't using "/home/google6821620603f54cd0.html" on the Alias line, you were, and I was telling you to change it to the live above. It should look similar to other Alias lines for other files in that directory you already have but you were missing the "WWWsiteServer/static/content" part of the path.

Graham

Bob Floyd

unread,
Dec 23, 2022, 12:59:32 PM12/23/22
to modwsgi
I tried and still get 404:
Alias /google6821620603f54cd0.html /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html
and confirmed the file is there:
ls /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html
and restarted apache:
sudo /etc/init.d/apache2 restart

If you navigate to nuv2.com you will see .ico and .jpg files in static/content loaded correctly, so I conclude the directory is reachable. It's only when I navigate in the browser to https:/nuv2.com/google6821620603f54cd0.html that I consistently get 404. It is as if 
WSGIScriptAlias / /var/www/wsgi/WWWsiteServer.wsgi
is being used to process the url (and there is no python route for it) instead of
Alias /google6821620603f54cd0.html /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html
but that doesn't make sense as the .ico and .jpg files load (but they also get 404 if navigated to). Something is different in asking for the files from within html code and asking for them in the browser url.

I see this in the error log after I enter https:/nuv2.com/google6821620603f54cd0.html in hte browser:

2022-12-23 17:56:40
Error
192.88.134.10
404
GET /google6821620603f54cd0.html HTTP/1.0

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54
2.30 K
Apache SSL/TLS access

Bob Floyd

unread,
Dec 23, 2022, 1:37:26 PM12/23/22
to modwsgi
PS. Interesting, if I navigate to https://www.nuv2.com/static/content/google6821620603f54cd0.html in the browser I get the file. I got the idea by noticing in the apache logs that asking from html had static/content in the url.  Hope this gives you some guidance as to what I've done wrong!

Bob Floyd

unread,
Dec 23, 2022, 1:44:09 PM12/23/22
to modwsgi
PPS If I remove the Alias for the google file from 000-default.conf the browser still loads the file at   https://www.nuv2.com/static/content/google6821620603f54cd0.html so am I correct to say the alias isn't doing anything?

Graham Dumpleton

unread,
Dec 23, 2022, 3:11:30 PM12/23/22
to mod...@googlegroups.com
Do note that those entries will only apply when you use:


with a port since you have it inside of a VirtualHost for that port.

<VirtualHost *:7080>

Graham

Bob Floyd

unread,
Dec 23, 2022, 5:05:30 PM12/23/22
to modwsgi
Hi Graham,

Ahh ha, you're on to something and now it works! Google search is indexing nuv2.com! Yea! When I signed up for hosting at GoDaddy I was looking for a VPS with Apache (so I could use mod_wsgi) and a version 20 of Ubuntu (version 18 didn't have full c++17 capabilities) and their only offering came with .... Plesk. I recall reading that it sat on port 443 and used port 7080 for Apache. I went into the Plesk panel and in the "Additional directives for HTTPS" edit box inserted:
Alias /google6821620603f54cd0.html /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html
<Directory /home/nuvroot/WWWsiteServer/static/content>
    Require all granted
</Directory>
The trouble with these user-friendly control panels is that they leave much room for improvement.  I have no idea where these lines went! Plesk creates files included in other files and around and around one can go looking instead of doing more productive stuff.

So now, waiting for google indexing, I'll tell my story, and ask a question.

Years ago Visual Studio introduced a website project using Python and Flask. Having used Python for other reasons, and never having built a website, that was a thumbs up for me and I created a new website project in VS. Thirty seconds later I'm looking at my browser with "Hello World". Thumbs and toes up! Then I noticed a "publish" button which I instantly assumed that, when the time came, would in give-or-take multiples of thirty seconds publish the website. Something to look forward to! Then that time arrived last Nov 6. I assumed the automation to host would be on Azure, naturally for VS to promote business on Azure. That's where I began, and a week later my ears were pouring three letter acronyms. But I hadn't found a thing about automation to host Python-flask. Like a dog with a bone I headed into the 2nd week searching, then, my account at Azure got stuck. It took two weeks for support to fix whatever happened, and during that time I thought perhaps a different hosting company would have templates setup for Python-Flask. So I got accounts at Network Solutions, Bluehost and GoDaddy. Well, that took another week to understand what they had to offer - WordPress and PHP and the capability of calling a Python function from HTML, but, nothing about Python-Flask. During my searching I easily came across your mod_wsgi, however, I was looking for the template and slide-in solution, which at this point I don't think exists. Now there's probably somebody out there who will respond with "did you look here..." and I'll be red-faced at having spent 6 weeks to reach hosting. By now, Azure fixed my account, and I went back there to continue, having decided to bite the bullet and compile mod_wsgi. I sure didn't want to start with an empty VM and have to install Apache also, so I found on the Azure marketplace an offering of a VM with Apache. I got that and began my cheat sheet, now with some 44 steps, to compile the correct version of Python, mod_wsgi, edits to the .conf file etc. It worked, got "Hello Lisa" in my browser. That's when I discovered Ubuntu 18 didn't have all the c++17 std lib functionality and decided to go host on GoDaddy. With my cheat sheet in hand it only took a few days to get my home page up. Yea! But I had issues with SSL and phoned the VPS support line, got a great person who identified several issues and fixed them. Before ending the call, I asked "I'm wondering how many customers you have that have websites written in Python-Flask?" He replied, "What was the last word?" "Flask" I said. "You're the first" to which I replied the whole website is written in Python using Flask, take a look at it. "That loaded fast" he said. "I'll have to look into that".

So what you've done with mod_wsgi is fantastic, and I still wonder how many people use the configuration to host?

Well, I hope my story amuses enough to make up for the fumbling on my part!

Have a Merry Christmas and thanks,
Bob 

Graham Dumpleton

unread,
Dec 23, 2022, 5:13:29 PM12/23/22
to mod...@googlegroups.com

On 24 Dec 2022, at 9:05 am, Bob Floyd <bobfl...@gmail.com> wrote:

Hi Graham,

Ahh ha, you're on to something and now it works! Google search is indexing nuv2.com! Yea! When I signed up for hosting at GoDaddy I was looking for a VPS with Apache (so I could use mod_wsgi) and a version 20 of Ubuntu (version 18 didn't have full c++17 capabilities) and their only offering came with .... Plesk. I recall reading that it sat on port 443 and used port 7080 for Apache. I went into the Plesk panel and in the "Additional directives for HTTPS" edit box inserted:
Alias /google6821620603f54cd0.html /home/nuvroot/WWWsiteServer/static/content/google6821620603f54cd0.html
<Directory /home/nuvroot/WWWsiteServer/static/content>
    Require all granted
</Directory>
The trouble with these user-friendly control panels is that they leave much room for improvement.  I have no idea where these lines went! Plesk creates files included in other files and around and around one can go looking instead of doing more productive stuff.

So now, waiting for google indexing, I'll tell my story, and ask a question.

Years ago Visual Studio introduced a website project using Python and Flask. Having used Python for other reasons, and never having built a website, that was a thumbs up for me and I created a new website project in VS. Thirty seconds later I'm looking at my browser with "Hello World". Thumbs and toes up! Then I noticed a "publish" button which I instantly assumed that, when the time came, would in give-or-take multiples of thirty seconds publish the website. Something to look forward to! Then that time arrived last Nov 6. I assumed the automation to host would be on Azure, naturally for VS to promote business on Azure. That's where I began, and a week later my ears were pouring three letter acronyms. But I hadn't found a thing about automation to host Python-flask. Like a dog with a bone I headed into the 2nd week searching, then, my account at Azure got stuck. It took two weeks for support to fix whatever happened, and during that time I thought perhaps a different hosting company would have templates setup for Python-Flask. So I got accounts at Network Solutions, Bluehost and GoDaddy. Well, that took another week to understand what they had to offer - WordPress and PHP and the capability of calling a Python function from HTML, but, nothing about Python-Flask. During my searching I easily came across your mod_wsgi, however, I was looking for the template and slide-in solution, which at this point I don't think exists. Now there's probably somebody out there who will respond with "did you look here..." and I'll be red-faced at having spent 6 weeks to reach hosting. By now, Azure fixed my account, and I went back there to continue, having decided to bite the bullet and compile mod_wsgi. I sure didn't want to start with an empty VM and have to install Apache also, so I found on the Azure marketplace an offering of a VM with Apache. I got that and began my cheat sheet, now with some 44 steps, to compile the correct version of Python, mod_wsgi, edits to the .conf file etc. It worked, got "Hello Lisa" in my browser. That's when I discovered Ubuntu 18 didn't have all the c++17 std lib functionality and decided to go host on GoDaddy. With my cheat sheet in hand it only took a few days to get my home page up. Yea! But I had issues with SSL and phoned the VPS support line, got a great person who identified several issues and fixed them. Before ending the call, I asked "I'm wondering how many customers you have that have websites written in Python-Flask?" He replied, "What was the last word?" "Flask" I said. "You're the first" to which I replied the whole website is written in Python using Flask, take a look at it. "That loaded fast" he said. "I'll have to look into that".

So what you've done with mod_wsgi is fantastic, and I still wonder how many people use the configuration to host?

One does not use traditional web hosting services for doing anything with Python as they are only setup for PHP and Wordpress. Apache/mod_wsgi is never usually supported on such shared hosting services for various reasons.

If you want a simpler path to hosting Python web applications go look at:


They don't use Apache/mod_wsgi but still should provide you an easier way to host Python applications.

Graham

Bob Floyd

unread,
Dec 23, 2022, 8:30:46 PM12/23/22
to modwsgi
I did look at pythonanywhere and didn't think it as "industrial" as Apache+mod_wsig. Am I wrong? Also, I'm on a VM at GoDaddy which should prevent possible security issues with anyone else on the PC as the Apache server I access is dedicated to my VM. No shared environment, so no security issue, right?

Graham Dumpleton

unread,
Dec 23, 2022, 8:36:08 PM12/23/22
to mod...@googlegroups.com
All depends on what you want to do, whether is more hobby, or production system for a critical company web site, plus how much traffic you expect to get. If have a dedicated VM then obviously can do whatever you want, but is going to be much more work.

Bob Floyd

unread,
Dec 24, 2022, 3:32:45 PM12/24/22
to modwsgi
Yes, and have a Merry Christmas and thanks for writing mod_wsgi!!
Reply all
Reply to author
Forward
0 new messages