Hot answers tagged

59

Almost there! Add this to ports.conf or http.conf and keep your above config. <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is ...


29

With any *nix application, the easiest method is to query the binary itself. In the case of httpd, I'd imagine the process would be something like this: $ whereis httpd /usr/sbin/httpd $ /usr/sbin/httpd -V Server version: Apache/2.2.11 (Unix) Server built: Jun 17 2009 14:55:13 Server's Module Magic Number: 20051115:21 Server loaded: APR 1.2.7, APR-Util ...


26

The easiest way to do this is through the Listen directive. By defaults, there's a line in our httpd.conf that reads: Listen *:80 Meaning it will respond ro requests on port 80 on all of your computer's network addresses. Changing it to: Listen 127.0.0.1:80 Will tell apache only to only respond to requests on the local adaptor, thus ignoring anything ...


22

apache2ctl -V | grep SERVER_CONFIG_FILE


19

You can use Include directive in httpd.conf to be able to maintain redirects in another file. But it would not be very efficient, as every request would need to be checked against a lot of regular expressions. Also a server restart would be required after every change in the file. A better way for so many redirects would be to use RewriteMap directive of ...


18

Information on apache httpd.conf files can be found at here. Some snippets have been copied from this website to ensure that the information is not lost if the link would deprecated: Include /usr/local/apache2/conf/ssl.conf Include /usr/local/apache2/conf/vhosts/*.conf Relative paths: Include conf/ssl.conf Include conf/vhosts/*.conf Wildcards: ...


17

mod_info provides what you need, I think. <Location /server-info> SetHandler server-info Order deny,allow Deny from all Allow from 1.2.3.4 # your IP, subnet, whatever </Location> More here: http://httpd.apache.org/docs/2.2/mod/mod_info.html You can also list the configuration of your VirtualHosts (less info than using the above) ...


17

Yes. conf.d files are included in Apache's configuration with a line like: Include conf.d/*.conf so changes are only noticed when the main configuration is reloaded. Note you can also use the 'graceful' restart (/etc/init.d/httpd graceful on some, apachectl graceful on others) to reload the configuration without dropping existing connections.


16

Directory directive works only for filesystem objects (e.g. /var/www/mypage, C:\www\mypage), while Location directive works only for URLs (the part after your site domain name, e.g. www.mypage.com/mylocation). The usage is straightforward - you would use Location if you need to fine tune access rights by an URL, and you would use Directory if you need to ...


15

I finally fixed this problem after testing several configuration parameters. I tested the solution twice, removing all previous changes. Only one parameter was needed for me to fix it. For the latest versions of httpd and mod_proxy_fcgi you can simply add timeout= to the end of the ProxyPassMatch line, e.g.: ProxyPassMatch ^/(.+\.php.*)$ ...


14

You should be able to do this using something like: server { server_name example.com; client_max_body_size 10m; # or whatever size limit you want error_page 413 /custompage.html; # you can also use a named location here if you like } http://wiki.nginx.org/HttpCoreModule#client_max_body_size http://wiki.nginx.org/HttpCoreModule#error_page


11

The listen option is probably best, but just as an FYI, you can do it using allow/deny like this <Directory /www/vhosts/localhost/> Options All AllowOverride All Order deny,allow Deny from all Allow from 127.0.0.1 </Directory> Order deny,allow tells Apache to "Deny all requests unless specifically allowed" (Order allow,deny ...


10

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 ...


9

Use mod_rewrite, something like this: RewriteEngine On RewriteCond %{HTTP_HOST} !^www.example.org [nocase] RewriteRule ^(.*)$ http://www.example.org$1 [last,redirect=301]


8

You are basically correct, however missing a subtlety in the use of Options. First, however, don't just stick them in the NameVirtualHost container, use a Directory Statement... You are correct that the most specific ones apply, however, if an options statement contains a list of options where every one is prefixed with a + or -, then the options are ...


8

In a typical environment, you can create a copy of httpd.conf and then modify the following properties on the new file. # pid file PidFile run/httpd.pid # http listen port Listen 80 # log files ErrorLog logs/error_log CustomLog logs/access_log combined # server name ServerName default_host_name # document root for the default site DocumentRoot ...


8

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


7

There are a few little details to get this working on Windows, but I've managed to do so with the following configuration: SetEnv GIT_PROJECT_ROOT d:/Export/GIT/ SetEnv GIT_HTTP_EXPORT_ALL ScriptAlias /git/ "C:/Progra~1/Git/libexec/git-core/git-http-backend.exe/" <Directory "C:/Program Files/Git/libexec/git-core/"> Options +ExecCGI Allow From All ...


7

Try ps ax | grep httpd and you should (might) get output like 1633 ?? Ss 0:00.21 /usr/sbin/httpd -f /etc/httpd.conf Additionally, how exactly are you restarting the server? Just curious in case you somehow aren't actually re-reading the config file.


7

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 ...


7

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 ...


6

a2enmod [enter] -> see all available modules apache2ctl -M -> see loaded modules (can be apachectl on RedHat)


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: http://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

In Apache 2.x you don't need to modify source code for increasing maximum clients above 255 like in Apache 1.3 you had to. Instead just tune your httpd.conf. Put there in prefork configuration section ServerLimit 1024 MaxClients 1024 And you should be all set.


6

You can do it with Include directive: Include /path/to/virtual_hosts.conf


6

I set SecRequestBodyAccess Off for now and that solved all problems.


5

htaccess example: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^en/contact$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTPS} =on RewriteRule !^en/contact$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond ...


5

On Ubuntu the main configuration file is /etc/apache2/apache2.conf However it's also split out into different files that can be found in /etc/apache2/conf.d /etc/apache2/sites-enabled /etc/apache2/mods-enabled There are also /etc/apache2/sites-available /etc/apache2/mods-available You should probably spend some time reading the documentation to get ...


5

Use Listen IP1:80 and it will only bind to that IP. http://httpd.apache.org/docs/2.2/bind.html When Apache starts, it binds to some port and address on the local machine and waits for incoming requests. By default, it listens to all addresses on the machine. However, it may need to be told to listen on specific ports, or only on selected ...



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