Docker Apache installation fails - apache

I am trying to start apache service with docker-compose up, but I get this error:
apache_1 | AH00526: Syntax error on line 15 of /usr/local/apache2/conf/httpd.conf:
apache_1 | Invalid command 'DirectoryIndex', perhaps misspelled or defined by a module not included in the server configuration
This is my Dockerfile for httpd:
FROM httpd:2.4
COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf
This is my httpd.conf file:
ServerName localhost
LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
LoadModule mpm_event_module /usr/local/apache2/modules/mod_mpm_event.so
#LoadModule mpm_prefork_module /usr/local/apache2/modules/mod_mpm_prefork.so
#LoadModule mpm_worker_module /usr/local/apache2/modules/mod_mpm_worker.so
<VirtualHost *:80>
DocumentRoot /var/www/html/
<Directory /var/www/html/>
DirectoryIndex index.html
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Send apache logs to stdout and stderr
CustomLog /proc/self/fd/1 common
ErrorLog /proc/self/fd/2
</VirtualHost>

I think you need to make sure you load the mod_dir module
LoadModule dir_module libexec/apache2/mod_dir.so

Related

how to enable http/2 on apache2 using ubuntu 20.04?

I have VPS server running ubuntu 20.04 (apache2) and is using http/1.1 and I want to upgrade to http/2
The domain is already configured using v-hosts (and has the ssl installed - lets encrypt).
Testing the current protocol:
$ curl -I https://my-domain.com
HTTP/1.1 200 OK
Date: Fri, 12 Mar 2021 17:32:01 GMT
Server: Apache/2.4.41 (Ubuntu)
Content-Type: text/html; charset=UTF-8
Steps that I done to upgrade to http/2:
1) sudo a2enmod http2
2) add in virtual host (ex: /etc/apache2/sites-enabled/my-domain.com-le-ssl.conf) the line:
Protocols h2 http/1.1
3) check the config
sudo apache2ctl configtest
4) Restart the web server
sudo systemctl reload apache2
Test again the ptotocol:
$ curl -I https://my-domain.com
HTTP/1.1 200 OK
Date: Fri, 12 Mar 2021 17:57:07 GMT
Server: Apache/2.4.41 (Ubuntu)
Upgrade: h2
Connection: Upgrade
Content-Type: text/html; charset=UTF-8
As you can see it still using the http/1.1
I also updated the apache2 from 2.4.41 -> 2.4.46 ... but the same problem.
What did I miss ???
** UPDATE **
apache2 loaded modules
$ sudo apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
expires_module (shared)
filter_module (shared)
headers_module (shared)
http2_module (shared)
mime_module (shared)
mpm_prefork_module (shared)
negotiation_module (shared)
php7_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)
php 7.4.3 installed
php
libapache2-mod-php
php-mysql
php-cli
php-mbstring
php-imagick
php-xml
php-gd
php-zip
php-curl
php-opcache
php-soap
php-bcmath
vhost config:
<VirtualHost *:80>
ServerAdmin admin#my-domain.com
ServerName my-domain.com
ServerAlias www.my-domain.com
DocumentRoot /var/www/my-domain.com/public
Protocols h2 http/1.1
<Directory /var/www/my-domain.com/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =my-domain.com [OR]
RewriteCond %{SERVER_NAME} =www.my-domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
and the ssl config:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin#my-domain.com
ServerName my-domain.com
ServerAlias www.my-domain.com
DocumentRoot /var/www/my-domain.com/public
Protocols h2 http/1.1
<Directory /var/www/my-domain.com/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/my-domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my-domain.com/privkey.pem
</VirtualHost>
</IfModule>
Replacing the mpm_prefork with mpm_event
using php-fpm (libapache2-mod-fcgid) instead of (libapache2-mod-php)
solve the problems.
You should probably add the --http2 option to your curl command

apache httpd 2.4.37 forward proxy not working

I have build apache httpd 2.4.37 from source in redhat and installed in home directory [/home/test/httpd-2.4.37]. as I don't have root access to install from yum. The server is running, I want to use this server only as a forward proxy.
I have the following modules in /home/test/httpd-2.4.37/conf/httpd.conf and the files in /home/test/httpd-2.4.37/modules
LoadModule proxy_module modules/mod_proxy.so LoadModule
proxy_connect_module modules/mod_proxy_connect.so LoadModule
proxy_ftp_module modules/mod_proxy_ftp.so LoadModule
proxy_http_module modules/mod_proxy_http.so LoadModule
proxy_fcgi_module modules/mod_proxy_fcgi.so LoadModule
proxy_scgi_module modules/mod_proxy_scgi.so LoadModule
proxy_uwsgi_module modules/mod_proxy_uwsgi.so LoadModule
proxy_fdpass_module modules/mod_proxy_fdpass.so LoadModule
proxy_wstunnel_module modules/mod_proxy_wstunnel.so LoadModule
proxy_ajp_module modules/mod_proxy_ajp.so LoadModule
proxy_balancer_module modules/mod_proxy_balancer.so
I have added below configuration at end of /home/test/httpd-2.4.37/conf/httpd.conf file.
Listen 127.0.0.1:8090
ProxyRequests On
ProxyVia On
ProxyPreserveHost Off
<Proxy "*">
Order deny,allow
Allow from all
</Proxy>
ErrorLog "/home/test/httpd-2.4.37/logs/proxy-error.log"
CustomLog "/home/test/httpd-2.4.37/logs/proxy-access.log" common
forward proxy is not working , when I call from a another machine using this proxy, I am getting connection refused as response.
no log is getting updated /home/test/httpd-2.4.37/logs/proxy-error.log & /home/test/httpd-2.4.37/logs/proxy-access.log
My primary objective is to tunnel ssh request over thru proxy. I have added the below change at the end of httpd.conf file. Proxy is working and forwarding the request to the destination.
Listen 8090
<VirtualHost *:8090>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^CONNECT [NC]
RewriteRule ^/(.*)$ - [F,L]
ProxyRequests On
ProxyBadHeader Ignore
ProxyVia On
AllowCONNECT 22 64
<Proxy "*">
Order deny,allow
Require ip 10
</Proxy>
ErrorLog "/home/test/httpd-2.4.37/logs/proxy-error.log"
CustomLog "/home/test/httpd-2.4.37/logs/proxy-access.log" common
</VirtualHost>

WAMP Virtualhost not working with Laravel instance

I'm working on a Laravel project locally using WAMP 3.1.0 and everything was working correctly until there was a windows update today.
When I go to my project I get an error page
I followed this post WAMP Virtual Host not working but that didn't solve my problem.
I've edited my C:\Windows\System32\drivers\etc\hosts file in admin mode which looks like this:
127.0.0.1 localhost
::1 localhost
127.0.0.1 test.dev
::1 test.dev
127.0.0.1 shoppingcart.dev
::1 shoppingcart.dev
127.0.0.1 gitproject.dev
::1 gitproject.dev
I've also edited my C:\wamp64\bin\apache\apache2.4.27\conf\extra\httpd-vhosts.conf file which looks like this:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
</VirtualHost>
<VirtualHost *:80>
ServerName test.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/test/public"
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "${INSTALL_DIR}/www/test/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName shoppingcart.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/shoppingcart/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gitproject.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/git_project/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
When I visit my page like this http://localhost/test/public/order/23456 my page loads but when I try http://test.dev/order/23456 it doesn't.
I'm using apache 2.4.27
Can anyone tell me what's going on?
Also, this is my C:\wamp64\bin\apache\apache2.4.27\conf\httpd.conf file :
ServerSignature On
ServerTokens Full
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.27
Define INSTALL_DIR c:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
ServerRoot "${APACHE_DIR}"
Listen 0.0.0.0:80
Listen [::0]:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "${INSTALL_DIR}/bin/php/php5.6.31/php5apache2_4.dll"
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin wampserver#wampserver.invalid
ServerName localhost:80
<Directory />
AllowOverride none
Require all denied
</Directory>
HostnameLookups Off
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "${INSTALL_DIR}/logs/access.log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "${INSTALL_DIR}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
</IfModule>
EnableSendfile off
AcceptFilter http none
AcceptFilter https none
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "${INSTALL_DIR}/alias/*"
The first thing you should know is that the .dev tLD is now a real tLD and has been bought by Google. So as of Chrome 63 (out since December 2017), Chrome itself will force all domains ending on .dev (and .foo) to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header.
So we should all stop using .dev and use something else, suggestions are to use .localhost or .test.
A simple test for this would be to try using FireFox or IE instead of Chrome to access your current configured site. If it runs in another browser, some of your problem is related to the Chrome changes that redirect .dev domains automatically.
Secondly, your Virtual Host definitions are not good. For some time now in WAMPServer there has been a tool provided within WAMPServer to help you create Virtual Hosts easily and correctly. Look at the WAMPSever homepage under the Tools menu for a link called Add Virtual Host (see below).
All you need to do is first create the folder that you want the site to live in before running the "Add Virtual Host" tool.
I suggest you revert your httpd-vhosts.conf file back to its initial state which contains only a definition for localhost
#
# Virtual Hosts
#
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
And then using the "Add Virtual Host" menu, create your Virtual Hosts again, but this time using paycafe.localhost for example.

Having a second document root server folder in Apache on El Capitan: access is forbidden

I want to define a second document root server folder in Apache2 in El Capitan 10.11.4. I could do that but it says access is forbidden. I tried these options:
I added this snippet to my username.conf
<Directory "/Users/username/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
I changed the permission over the username.conf by
sudo chmod 644 username.conf
I uncommented these lines in Httpd.conf
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
Include /private/etc/apache2/extra/httpd-userdir.conf
However, I commented these lines out with #:
<Directory />
221 AllowOverride none
222 Require all denied
223 </Directory>
I also uncommented this line:
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
Also in httpd-userdir.conf I uncommented
Include /private/etc/apache2/users/*.conf
But still it says access if forbidden! I was wondering if anyone can help me with that.
I had a similar issue, I was missing the Sites folder in my user home directory, I created that and then created a sample folder and index page and that fixed it for me.

Running multi tenancy on same port with apache web server - NameBasedVirtualHsoting

I have been working to get multi tenancy running on same port on same ip address. I have achieved the objective with different ports but I can't run the same on one port only.
Here the apache web server redirects the request to weblogic host on same machine.
I have gone through multiple guides but it is not working as expected. I have configured two virtual hosts for same port with URL as localhost:9010/site1 and localhost:9010/site2. The configuration in httpd.conf is mentioned below. I don't know where I have made the mistake so I have kept whole configuration file.
Define SRVROOT "D:\Apache24"
ServerRoot "${SRVROOT}"
Listen 9010
#Listen 9011
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule xml2enc_module modules/mod_xml2enc.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
<Directory />
AllowOverride ALL
Require all granted
</Directory>
DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex /home
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error.log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access.log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "${SRVROOT}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/css .css
AddType text/javascript .js
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/httpd-proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
ProxyRequests on
ProxyIOBufferSize 65536
SSLProxyEngine on
ErrorDocument 403 /home
ErrorDocument 404 /home
NameVirtualHost *:9010
<VirtualHost *:9010>
ServerName localhost:9010/site2
LogLevel info
<Location />
SetHandler weblogic-handler
</Location>
ProxyPass /site2 http://localhost:7001
ProxyPassReverse /site2 http://localhost:7001
ProxyPass /Login.zul http://localhost:7001/Login.zul
ProxyPassReverse /Login.zul http://localhost:7001/Login.zul
<IfModule mod_weblogic.c>
WebLogichost localhost
WebLogicPort 7001
debug OFF
FileCaching OFF
MatchExpression *
KeepAliveSecs 540
</IfModule>
</VirtualHost>
<VirtualHost localhost:9010>
ServerName localhost:9010/site1
LogLevel info
<Location />
SetHandler weblogic-handler
</Location>
ProxyPass /site1 http://localhost:7001
ProxyPassReverse /site1 http://localhost:7001
ProxyPass /Login.zul http://localhost:7001/Login.zul
ProxyPassReverse /Login.zul http://localhost:7001/Login.zul
<IfModule mod_weblogic.c>
WebLogichost localhost
WebLogicPort 7001
debug OFF
FileCaching OFF
MatchExpression *
KeepAliveSecs 540
</IfModule>
</VirtualHost>
Whenever I use different ports for site1 and site2, it runs fine. But keeping the same port does not work for me. Only the virtualhost defined first works and the other returns eorro 404.
Also I found that it is called as Name based virtual hosting. The guides suggests that NameVirtualHost directive should be configured. I have also added the same.
Please help... Thank you in advance..
If you are running 2 VirtualHosts on the same port, the differentiator would be the Servername, such as:
<VirtualHost *:9010>
ServerName site1.localhost.local
......
</VirtualHost>
<VirtualHost *:9010>
ServerName site2.localhost.local
......
</VirtualHost>
In your examples you are using subdirectory as you servername and this is not work, that seems to be the issue