Tag Info

Hot answers tagged

27

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


18

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


18

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


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

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


15

apache2ctl -V | grep SERVER_CONFIG_FILE


12

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


10

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


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

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. <Proxy fcgi://127.0.0.1:49158> ProxySet timeout=1800 </Proxy> ProxyPassMatch ^/(.+\.php.*)$ fcgi://127.0.0.1:49158/home/...<your_path> I needed to add ...


7

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


7

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


7

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


6

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.


6

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


5

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


5

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


5

I've not tested this, but, if you set an environment variable you should be able to switch which file it logs to: SetEnvIf Request_URI "/fogbugz/heartbeat\.asp$" is_heartbeat_request=1 CustomLog /var/log/httpd/heartbeat_log combined env=is_heartbeat_request CustomLog /var/log/httpd/access_log combined env=!is_heartbeat_request


5

The Apache manual section on mod_authz_host is instructive here. The order of your allow and deny statements does not matter. With order allow,deny, you must match at least one allow and no deny directives for your request to be accepted. I think you want order deny,allow.


5

You're running out of swap because you're using all your RAM and then some. You have a serious problem that you need to rectify right now. You have two choices: ignore cause and just add more RAM, or target the problem of what's actually munching on your memory. Adding RAM is fairly cheap and fairly easy if it's your server but it's a temporary fix and if ...


5

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


5

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.


5

Yes, they are equivalent in the aspect of both providing the same result, only allowing access from 127.0.0.1. Let me quote the relevant part from the documentation on the Order directive. Allow,Deny First, all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any ...


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


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


4

It depends on a directive. For example you can use several Listen directives and Apache will listen on every defined port. But if you use several StartServers directives only the last will apply (I just checked that on my setup). I guess default behaviour is to apply the last directive (and Listen is one of exceptions to that rule) so the timeout will be ...


4

Authentication always applies to a context; this may be a VirtualHost, a Directory, or a Location. <Location /> AuthType Basic AuthName "Development Area" AuthUserFile /var/www/.htpasswd Require valid-user </Location />


4

If it were me, I'd store the shared configurations in "fragment" .conf files and use the Include directive in each VirtualHost or other place that shares the configurations within those fragments. i.e. Include conf-fragments/error-log.conf Include conf-fragments/Directory-mail.conf


4

I would advice against doing this using an iptables redirect. The reason is that when someone browses your site using HTTP, their browser is not expecting an SSL session handshake. It may work, but it's definitely not guaranteed to. Instead, I'd have a separate Apache instance (or a VirtualHost) that listens on port 80. That apache instance/VH should be ...



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