mod_wsgi icon indicating copy to clipboard operation
mod_wsgi copied to clipboard

Running mod_wsgi-express, loading the website loads Apache Directoryindex

Open droidzone opened this issue 2 years ago • 1 comments

I installed mod-wsgi with pip install mod-wsgi on a Ubuntu 22 server which has a default installation, with apache2 installation. I downloaded certificates with letsencrypt, and ran mod_wsgi-express with the following command:

mod_wsgi-express setup-server wsgi.py --https-port 443 --https-only --server-name myurl.com --server-alias '*.myurl.com' --ssl-certificate-file ssl-certs/cert1.pem --ssl-certificate-key-file ssl-certs/privkey1.pem --user www-data --group www-data 

I got the following:

Server URL         : http://myurl.com:8000/
Server URL (HTTPS) : https://myurl.com/
Server Root        : /tmp/mod_wsgi-localhost:8000:0
Server Conf        : /tmp/mod_wsgi-localhost:8000:0/httpd.conf
Error Log File     : /tmp/mod_wsgi-localhost:8000:0/error_log (warn)
Rewrite Rules      : /tmp/mod_wsgi-localhost:8000:0/rewrite.conf
Environ Variables  : /tmp/mod_wsgi-localhost:8000:0/envvars
Control Script     : /tmp/mod_wsgi-localhost:8000:0/apachectl
Operating Mode     : daemon
Request Capacity   : 5 (1 process * 5 threads)
Request Timeout    : 60 (seconds)
Startup Timeout    : 15 (seconds)
Queue Backlog      : 100 (connections)
Queue Timeout      : 45 (seconds)
Server Capacity    : 20 (event/worker), 20 (prefork)
Server Backlog     : 500 (connections)
Locale Setting     : en_US.UTF-8

I started the server with:

/tmp/mod_wsgi-localhost:8000:0/apachectl start

I got the following from log:

[Tue May 23 16:41:11.860961 2023] [ssl:warn] [pid 49630:tid 140223593949056] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue May 23 16:41:11.870044 2023] [ssl:warn] [pid 49632:tid 140223593949056] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue May 23 16:41:11.875896 2023] [ssl:warn] [pid 49632:tid 140223593949056] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue May 23 16:41:11.876890 2023] [mpm_event:notice] [pid 49632:tid 140223593949056] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.4 Python/3.10 OpenSSL/3.0.2 configured -- resuming normal operations
[Tue May 23 16:41:11.877055 2023] [core:notice] [pid 49632:tid 140223593949056] AH00094: Command line: 'apache2 (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -D MOD_WSGI_VIRTUAL_HOST -D MOD_WSGI_WITH_HTTPS -D MOD_WSGI_HTTPS_ONLY -D MOD_WSGI_SERVER_ALIAS -D MOD_WSGI_KEEP_ALIVE -D MOD_WSGI_MPM_ENABLE_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_WORKER_MODULE -D MOD_WSGI_MPM_EXISTS_PREFORK_MODULE'
[Tue May 23 16:41:13.258355 2023] [wsgi:error] [pid 49633:tid 140223593949056] BASE_DIR:  /home/joel/shortcode

On loading https://myurl.com in my web browser I get an empty listing of the default apache Directory Listing

droidzone avatar May 23 '23 11:05 droidzone

How was the certificate generated when you say "I downloaded certificates with letsencrypt". Based on what you are using it would need to be a wildcard certificate, with addition of also allowing for the top level domain. LetsEncrypt can do a wildcard domain, but I am not familiar how you attach the parent domain to the same certificate. A wildcard certificate of *.myurl.com will not match parent domain of myurl.com as I understand it.

Also, are you sure the request is going to that Apache instance? Use the --access-log option to turn on access logging so you can see if a request was received.

GrahamDumpleton avatar May 23 '23 20:05 GrahamDumpleton