Unanel to find a virtual host listening on port 80


#4

This is a config with aholab.ehu.es_ as ServerName, there is one _ too much.

Your config with all these _ looks curious. Or completely wrong.


#6

Sorry, the _ lines were added by the web editor when I tried to put that lines in italics… they are not in the original files. The http-like syntax of the .conf files is misunderstood by the web editor, so I have uploaded the text files.I hope you will recive them without problems.
Thanks

aholab.conf.txt (699 Bytes)
aholab-ssl.conf.txt (635 Bytes)


#7

Your config looks ok.

What’t the content of

/etc/apache2/sites-available
/etc/apache2/sites-enabled

Your file should be in the first directory, in the second, there should be a symlink.

What says

apachectl -t -D DUMP_VHOSTS

#8

It is like you say: the .conf files are in sites-available and symlinks in sites-enabled
The output of apachectl follows (as I told you there are other vhosts)

VirtualHost configuration:
*:443 aholab.ehu.es (/etc/apache2/sites-enabled/000-aholab-ssl.conf:4)
*:80 is a NameVirtualHost
default server aholab.ehu.es (/etc/apache2/sites-enabled/000-aholab.conf:2)
port 80 namevhost aholab.ehu.es (/etc/apache2/sites-enabled/000-aholab.conf:2)
alias www.aholab.ehu.es
alias www.bips.bi.ehu.es
alias bips.bi.ehu.es
alias u002887.bi.ehu.es
port 80 namevhost fundacion.sharerip.com (/etc/apache2/sites-enabled/fundacion.conf:3)
alias www.fundacion.sharerip.com
port 80 namevhost jth2008.ehu.es (/etc/apache2/sites-enabled/jth2008.conf:3)
alias jth2008.ehu.es
port 80 namevhost tool.jth2008.aholab.ehu.es (/etc/apache2/sites-enabled/jth2008.conftool.conf:3)
alias tool.jth2008.aholab.ehu.es


#9

Upps - that may be your problem.

You have two server with the same name. Remove the default.


#10

I think the problem may be in your redirection statements:
Redirect permanent / https://aholab.ehu.es/
redirects (correctly) to https.
So, http://aholab.ehu.es/.well-known/acme-challenge/1234
forwards to: https://aholab.ehu.es/.well-known/acme-challenge/1234
But the TLS server block also has a redirection statement:
RedirectMatch ^/$ /aholab/
So, now the (new) request to: https://aholab.ehu.es/.well-known/acme-challenge/1234
is “mangled” to?: https://aholab.ehu.es/aholab/.well-known/acme-challenge/1234
Which should get the content from /var/ww/aholab/.well-known/acme-challenge/1234
But the --webroot specifies /var/www
So the challenge files end up at: /var/www/.well-known/acme-challenge/1234
Not where that are actually being server from (/var/www/aholab/.well-known/acme-challenge/1234).

You can try updating the command with -w /var/www/aholab
[to force them to match]
If this fails, the we need to exclude the /.well-known/acme-challenge from
RedirectMatch ^/$ /aholab/
Or ensure the redirection doesn’t cause other problems (like truncating the full URL)

[edit - corrected my dyslexia and added this thought]
Since it seems that 100% of the connections will go to the redirected path…
Why not remove the redirection and just update the document root?
from:

        DocumentRoot /var/www/
        RedirectMatch ^/$ /aholab/

to:

        DocumentRoot /var/www/aholab/
        #RedirectMatch ^/$ /aholab/

#11

The current problem: Certbot doesn’t want to start, because Certbot doesn’t find a vHost.

So no challenge file is created.


#12

Maybe I didn’t read back far enough…
But I thought the use of --webroot overrides that kind of checking.


#13

Thank you both for your help. Actually, I don’t see any way to remove the default server. As far as I know, the first vhost of the config files is automatically assumed by apache as the default server. I suppose I could change the .conf file name so as apache reads first another vhost file, and thus takes another vhost as the default one, but I don’t think I can remove it.


#14

I think he meant for you to remove (or change) the repeated name in that file.


#15

Can you show this file?:
/etc/apache2/sites-enabled/000-aholab.conf


#16

But there is not a duplicated name anywhere. That was the output of apachectl -t -D DUMP_VHOST. The actual .conf files only define each vhost once


#17

I think you may be right.
[I’m not too familiar with that output]


#18

I uploaded it

Blockquote
it is the first one, aholab.conf.txt
I had problems pasting the contents in your web editor and that’s why I had to upload it


#19

OK I agree with you; the output can be misread too easily it seems.
Did you read through post #10?: Unanel to find a virtual host listening on port 80


#20

Sorry, wrong words. Change your default server.

Both servers use the same file, both servers have aholab.ehu.es as name.

So Certbot doesn’t know which is used. And I don’t know the same.

So create a new file (perhaps empty), use this as file with your default server. And change the name of your default server (another name, not relevant).

So this

port 80 namevhost aholab.ehu.es (/etc/apache2/sites-enabled/000-aholab.conf:2)

is unique.

PS: Perhaps the error message is wrong. Not “unable to find a vHost”, instead “opps, there are two vHosts - which is the correct?”


#21

I have created a 000-default.conf file

<VirtualHost _default_:80>
<Location />
Deny from all
Options None
ErrorDocument 403 Forbidden.
</Location>
</VirtualHost>

*The indentation is lost due to your web editor…

and now apachectl -t -S gives:

VirtualHost configuration:
*:443 aholab.ehu.es (/etc/apache2/sites-enabled/010-aholab-ssl.conf:4)
*:80 is a NameVirtualHost
default server aholab.ehu.es (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost aholab.ehu.es (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost aholab.ehu.es (/etc/apache2/sites-enabled/010-aholab.conf:2)
alias www.aholab.ehu.es
alias www.bips.bi.ehu.es
alias bips.bi.ehu.es
alias u002887.bi.ehu.es
port 80 namevhost fundacion.sharerip.com (/etc/apache2/sites-enabled/fundacion.conf:3)
alias www.fundacion.sharerip.com
port 80 namevhost jth2008.ehu.es (/etc/apache2/sites-enabled/jth2008.conf:3)
alias jth2008.ehu.es
port 80 namevhost tool.jth2008.aholab.ehu.es (/etc/apache2/sites-enabled/jth2008.conftool.conf:3)
alias tool.jth2008.aholab.ehu.es
ServerRoot: “/etc/apache2”
Main DocumentRoot: “/var/www”
Main ErrorLog: “/var/log/apache2/error.log”
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex fcgid-pipe: using_defaults
PidFile: “/var/run/apache2/apache2.pid”
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: MODPERL2
Define: ENABLE_USR_LIB_CGI_BIN
User: name=“www-data” id=33
Group: name=“www-data” id=33

certbot-auto gives the same error
Unable to find a virtual host listening on port 80


#22

Prepend and postpend your “difficult” sections with a single line containing three backticks.
Like:

```
text that garbles
```

#23

Is this now a triple definition?

Certbot requires one unique vHost with the name aholab.ehu.es


#24

Is certbot-auto running on the same system?
[this is very bizarre]