You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Paul Claridge <pa...@vicjenmail.plus.com> on 2021/05/03 10:05:05 UTC

[users@httpd] Trying to serve pages to localhost

Esteemed helpers,
I have a Ubuntu 20.04 LAMP server running apache2 2.4.41

I have a VirtualHost on 443 with a letsencrypt certificate, and it works 
fine. I have constructed a page and proved it renders on this 
VirtualHost. The page displays a bootstrap modal.

What I want to do is render that modal on a local browser and then 
screenshot it and write it to a file.

I came across the nodejs lib puppeteer which does exactly what I want.

My problem is I cannot reliably serve pages to the node app. After one 
or two successful runs the node app hangs waiting for the modal to be 
displayed.

I have set up another VirtualHost localhost:80, pointing to the same 
document root as my working VH, and make requests for my page using 
http://localhost/...

I have configured logging in both VH's but requests are appearing in my 
SSL log and not the (different) localhost (http) log.

I think I might be missing something fundamental here about the way 
localhost is treated?

Can anyone point me in the right direction please? I feel this can be 
done, but am going round in circles currently.

I do have mod_security installed and have been watching the logs 
carefully. I have added a rule to allow 127.0.0.1

All/any help much appreciated, regards, Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trying to serve pages to localhost

Posted by Eric Covener <co...@gmail.com>.
> mydomain.com.conf:
> <VirtualHost *:80>
...
>         #ServerName www.example.com

This can be problematic, I suggest choosing an explicit ServerName here.
Otherwise the systems own hostname is substituted and when you add a
later virtualhost with it, it will be unreachable
Probably not the culprit right now though.

> localhost2.conf:
> <VirtualHost localhost:80>
I strongly suggest *:80 above.  Hostnames inside <virtualhost> are a
red flag I check for first for these kinds of vhost mapping issue

>         #ServerName www.example.com
ServerName localhost to go with the *:80

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trying to serve pages to localhost

Posted by Paul Claridge <pa...@vicjenmail.plus.com>.
On 03/05/2021 12:34, Eric Covener wrote:
>> I have configured logging in both VH's but requests are appearing in 
>> my
>> SSL log and not the (different) localhost (http) log.
>> 
>> I think I might be missing something fundamental here about the way
>> localhost is treated?
> 
> Can you paste the output of apachectl -S and the config for the two
> <virtualhosts> ?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

sudo apachectl -S:

VirtualHost configuration:
[::1]:80               localhost 
(/etc/apache2/sites-enabled/localhost2.conf:1)
127.0.0.1:80           localhost 
(/etc/apache2/sites-enabled/localhost2.conf:1)
*:443                  mydomain.com 
(/etc/apache2/sites-enabled/mydomain.com-le-ssl.conf:2)
*:80                   mydomain.com 
(/etc/apache2/sites-enabled/mydomain.com.conf:4)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: MODSEC_2.5
Define: MODSEC_2.9
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33


mydomain.com.conf:

#
# Virtual host for ikulpic site goodnewsbig.com
#
<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port 
that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) 
this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	DocumentRoot /var/www/html/gnb
	ServerName mydomain.com
	ServerAlias www.mydomain.com
	ServerAdmin paul@vicjen.co.uk
	DirectoryIndex index.php
	Alias /res/ /var/www/html/res/
	<Directory /var/www/html/gnb>
		Options -Indexes
		AllowOverride All
                 Require all granted
         </Directory>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn
	LogLevel warn

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

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

mydomain.com-le-ssl.conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>
	# The ServerName directive sets the request scheme, hostname and port 
that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) 
this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	DocumentRoot /var/www/html/gnb
	ServerName mydomain.com
	ServerAlias www.mydomain.com
	ServerAdmin paul@vicjen.co.uk
	DirectoryIndex index.php
	Alias /res/ /var/www/html/res/
	<Directory /var/www/html/gnb>
		Options -Indexes
		AllowOverride All
                 Require all granted
         </Directory>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn
	LogLevel warn

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

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteCond %{SERVER_NAME} =mydomain.com
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} 
[END,NE,R=permanent]

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
</VirtualHost>
</IfModule>

localhost2.conf:

<VirtualHost localhost:80>
	# The ServerName directive sets the request scheme, hostname and port 
that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) 
this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin paul@vicjen.co.uk
	DocumentRoot /var/www/html/gnb
	DirectoryIndex index.php
	Alias /res/ /var/www/html/res/
	<Directory /var/www/html/gnb>
		Options -Indexes
		AllowOverride All
                 Require all granted
         </Directory>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

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

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trying to serve pages to localhost

Posted by Eric Covener <co...@gmail.com>.
> I have configured logging in both VH's but requests are appearing in my
> SSL log and not the (different) localhost (http) log.
>
> I think I might be missing something fundamental here about the way
> localhost is treated?

Can you paste the output of apachectl -S and the config for the two
<virtualhosts> ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org