55

Solution is on Apache 2.2 documentation on the Virtualhost directive: Syntax: ... (...) Addr can be: The IP address of the virtual host; A fully qualified domain name for the IP address of the virtual host (not recommended); The character *, which is used only in combination with NameVirtualHost * to match all IP addresses; or The ...


23

There's another serverfault question regarding this. If you're using a debian based server you can use apache2ctl to determine which config file is being used: apache2ctl -V More on this: How to find out which httpd.conf apache is using at runtime


22

The recommendation from the Apache project is: In general, you should only use .htaccess files when you don't have access to the main server configuration file. ... a common misconception is that user authentication and mod_rewrite directives must go in .htaccess files. So please both set AllowOverride None and all your other directives in the main httpd....


16

You just need to change your Listen directives to: Listen [::]:80 Listen [::]:443 while your NameVirtualHost *:80 <VirtualHost *:80> remain the same. Note: netstat -tln will show apache listening only on tcp6 / :::80; that is normal (it will also respond to IPv4 as before)


10

I wanted to point out that although this answer works great for older versions, it breaks under recent versions of Apache 2.4 with error code AH00526. ProxyPass and ProxyPassMatch or <Proxy> and <ProxyMatch> cannot be used together within the same worker name. This used to function just fine, so don't know if that was changed by design or if it's ...


10

Thanks for the other answers. I solved it by adding a default virtual host without any permissions. The global DocumentRoot and ServerName options must match the ones specified in the virtual host. /etc/httpd/conf/httpd.conf ... ServerName <server-ip>:80 DocumentRoot "/var/www/html" <Directory /> Order Deny,Allow Deny from all ...


9

try mod_macro Here is an example: ## Define a VHost Macro for repetitive configurations <Macro VHost $host $port $dir> Listen $port <VirtualHost *:$port> ServerName $host DocumentRoot $dir # Public document root <Directory $dir> Require all granted </Directory> # limit access to intranet subdir. &...


8

I ran into the same exact issue. SecRequestBodyNoFilesLimit was the reason. it was not used in my config at all, but it does have a default value, 1048576. Once I found that this setting existed, I set it larger than my files and everything is working. Here is the documentation https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#wiki-...


8

I think you need to wrap your existing it.example.com definition in a <VirtualHost> block. I think this is being caused because without the vhost definition for it.example.com, kb.example.com becomes the default vhost. In the event that a suitable vhost isn't found this is what will be served which then comes back to itself ...


8

You do not need it. I just checked on a server with over a hundred apache virtual domains, none of them have ServerAdmin defined. The ServerAdmin is commented out in the main config file (httpd.conf) and I guess there hasn't been a problem so far. In fact it seems like apache no longer displays the ServerAdmin in any event?


8

Yes and No. You can comment out or remove the DocumentRoot directive, no problem. But that doesn't achieve much, because then it will default to the default directory PREFIX/htdocs/ where PREFIX is set when you build apache. When you have VirtualHosts set up all requests that are not handled by an explicitly configured virtual host get handled by the ...


8

concerning relayd I guess something like would achieve what you want : This defines the ip where you can find the foo "service" it's a list of host basically (pf style) table <fooservice> { 192.168.30.3 } table <barservice> { 192.168.30.4 } Here you define a template for the rules to apply in a relay section you match the request with the ...


7

Looks like an old question now, but I wanted to do the same and found the answer from nerve above. It's not quite right as is - seems to me that it should be <Location "/">, and the SetEnvIf needs a regular expression so the parentheses need to be quoted. This worked for me to apply the access control across all vhosts: SetEnvIfNoCase User-Agent "^...


7

I have Apache 2.4.6, but the patch to fix it is provided in Apache >= 2.4.8. The key here is to start your output immediately so that Apache (mod_proxy_fcgi) thinks the connection is active. For example, I am using PHP and the DB query for my AJAX call takes > 30 seconds. Because I know that the overall response will be "Content-Type: application/json", I ...


7

By default, in CentOS, there is a file used by Apache/httpd located at /etc/httpd/conf.d/ssl.conf. This file is read in as a configuration by Apache along with the "httpd.conf" file and anything in it takes precedence over settings in httpd.conf. That file (again by default) contains a Listen 443 directive. You cannot call that directive twice (as it will ...


7

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service and "journalctl -xe" for details. (empahsis mine) How do I solve this error? Read the error message carefully, note that it provides useful information on what to do to gather more information, specifically it mentions 2 commands that you ...


6

You cannot use variables in log location directives. The way to do it is to pipe the log to another program. Here is a possible solution: https://stackoverflow.com/questions/20217533/dynamic-apache-log-directory-based-on-hostname


6

Yes - they are reporting different version numbers hence are different instances of Apache. /usr/local/apache2 is the default base directory for a apache compiled from source, while the other one with files in /usr/sbin and /etc is the Ubuntu distributed version. Unless you have a very specific reason for doing otherwise it is best practice to stick with ...


6

Yes, to a certain degree, but I think it covers your requirement. You can use mod_info for this. From the online documentation (emphasis mine): Dumping the configuration on startup If the config define -DDUMP_CONFIG is set, mod_info will dump the pre-parsed configuration to stdout during server startup. Pre-parsed means that directives like <...


6

Every Directive lists the context in which it is valid. In other words where it is allowed to be used. The context can be any combination of: s - server config This means that the directive may be used in the server configuration files (e.g., httpd.conf), but not within any <VirtualHost> or <Directory> containers. It is not allowed in ....


6

Having spent some time on this it seems that the Apache documentation could be misleading, although I may have missed something. It says IPv6 addresses must be enclosed in square brackets. This is true for non link-local addresses. But I have now discovered that link-local addresses can be used, and must include a scope id, but without the square brackets. ...


6

The reqenv function must be compared against something, you cannot just check for the environment variable to be set or not as your code tries to. I admit the error message is not particularly enlightening :-) The following should work for you: SetEnvIf Request_URI ^/(img|js|css|thumb|banner) static=yes SetEnvIf Remote_Addr "127.0.0.1" dontlog=yes ...


5

In case of Options either you have to use * or - sign with all or with none; i.e. Options FollowSymLinks -MultiViews -Indexes is wrong. If you are using + or - sign, you have to use for all options i.e. Options +FollowSymLinks -MultiViews -Indexes


5

With an AllowOverride None setting in the httpd.conf the .htaccess file is completely ignored. So you have to change that setting. When .htaccess files are allowed, apache will check each directory from the DocumentRoot down for the existance of a .htaccess file AND will apply the settings there, before desccending down to the next directory and the ....


5

Does that mean that RewriteEngineOn can be used multiple times within httpd.conf? Yes, that's fine. I'm assuming that it can be but it must be placed within directory blocks. No, it's valid in any configuration context, and will inherit down to other contexts - so if you have it enabled at the <VirtualHost>, you don't need it within <Directory&...


5

rotatelogs requires a full path. Prepending the ServerRoot to relative paths (i.e those not not starting with a / or driveletter:\) happens only within Apache and external programs such as rotatelogs are not aware of Apache's ServerRoot variable.


5

Yes, you have two Apache installations on your VPS. You have Apache installed from the ubuntu repositories, installed in /usr You have Apache installed from source installed in /usr/local/apache2 Now, you stated in a comment that you tried to uninstall apache before reinstalling from source. It would appear that the uninstallation did not properly ...


5

I'm not sure you want to do that. If there is no default vhost in an apache config, the first defined vhost becomes the default. All you really need to do is have the default serve a blank page.


5

It really depends on exactly what you are doing and what configuration directives you are using. If you want to start with an absolute minimal configuration and then build up from there, there is an example on the Apache httpd wiki here: https://wiki.apache.org/httpd/Minimal_Config Then you could add mod_proxy, mod_proxy_ajp and whatever other modules you ...


5

The problem was solved but there was some misunderstandings. There really is the requirement that HTTPS needs a matching certificate, but the problem caused by this is that the connection won't be trusted with hostname not matching certificates Common Name or listed in Subject Alternative Name: The same mismatch stays even with the RewriteRule solution ...


Only top voted, non community-wiki answers of a minimum length are eligible