Category Archives: apache-config

Apache not reporting HTTPS server variable to PHP

Trying to get Apache 2.4.33 on an AWS EC2 instance to terminate an SSL certificate correctly, it doesn't seem to populate the HTTPS environment variable to PHP, and .htaccess rewrite rules don't work at all.

This is my setup:

/etc/httpd/conf/httpd.conf:

<Directory "/var/www/">
Options -Indexed +FollowSymLinks -MultiViews
AllowOverride all
Require all granted
</Directory>

/etc/httpd/conf.d/ssl.conf:

Listen 443 https
<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/cert.crt
SSLCertificateKeyFile /etc/pki/tls/private/private.key
SSLCertificateChainFile /etc/pki/tls/certs/chain.ca-bundle
</VirtualHost>

/etc/httpd/conf.d/vhosts.conf:

<VirtualHost *:80 *:443>
DocumentRoot /var/www/example.com
ServerName example.com
ServerAlias www.example.com
UseCanonicalPhysicalPort on
</VirtualHost>

/var/www/example.com/.htaccess:

RewriteEngine on

#if ELB http
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]

#if server http
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on

#if www.
RewriteCond %{HTTP_HOST} ^www\. [NC]

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

And this is what PHP reports:

  1. for http://example.com (which for some reason is not enforced, despite .htaccess):

$_SERVER['HTTPS'] = NULL

$_SERVER['SERVER_PORT'] = '80'

  1. for https://example.com:

$_SERVER['HTTPS'] = NULL

$_SERVER['SERVER_PORT'] = '443'

The only reason the port is correct is due to UseCanonicalPhysicalPort, but why is the HTTPS variable always null, and why doesn't .htaccess do anything?

Apache not reporting HTTPS server variable to PHP

Trying to get Apache 2.4.33 on an AWS EC2 instance to terminate an SSL certificate correctly, it doesn't seem to populate the HTTPS environment variable to PHP, and .htaccess rewrite rules don't work at all.

This is my setup:

/etc/httpd/conf/httpd.conf:

<Directory "/var/www/">
Options -Indexed +FollowSymLinks -MultiViews
AllowOverride all
Require all granted
</Directory>

/etc/httpd/conf.d/ssl.conf:

Listen 443 https
<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/cert.crt
SSLCertificateKeyFile /etc/pki/tls/private/private.key
SSLCertificateChainFile /etc/pki/tls/certs/chain.ca-bundle
</VirtualHost>

/etc/httpd/conf.d/vhosts.conf:

<VirtualHost *:80 *:443>
DocumentRoot /var/www/example.com
ServerName example.com
ServerAlias www.example.com
UseCanonicalPhysicalPort on
</VirtualHost>

/var/www/example.com/.htaccess:

RewriteEngine on

#if ELB http
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]

#if server http
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on

#if www.
RewriteCond %{HTTP_HOST} ^www\. [NC]

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

Edit: .htaccess has -rw-rw-r-- permissions.

And this is what PHP reports:

  1. for http://example.com (which for some reason is not enforced, despite .htaccess):

$_SERVER['HTTPS'] = NULL

$_SERVER['SERVER_PORT'] = '80'

  1. for https://example.com:

$_SERVER['HTTPS'] = NULL

$_SERVER['SERVER_PORT'] = '443'

The only reason the port is correct is due to UseCanonicalPhysicalPort, but why is the HTTPS variable always null, and why doesn't .htaccess do anything?

Edit: Per Patrick's comment, I've split the ports into one exclusive VirtualHost for each port, and removed the UseCanonicalPhysicalPort directive. This seems to have solved the first issue, and PHP now correctly displays both the $_SERVER['HTTPS'] and SERVER_PORT variables.

The second issue remains though: .htaccess rewrite rules are still not working.

Thanks for any insight!

Redmine: can’t get 2 instances running at the same time

I can't get 2 redmines to run at the same time in a Debian 7 server. Using Apache2 and Passenger (ruby rails)

The applications both work in test environment (Webrick server) and both work if I declare ONLY one virtual host in the apache config file. But if I declare both, this way, only the first one works:

<VirtualHost *:80>
  ServerName <myURL>/requests

  DocumentRoot /var/www/
  RailsEnv production   

  #PassengerRuby /usr/local/bin/ruby
  #PassengerLogLevel 4
  #RailsBaseURI /var/www/myapp/public

  Alias /requests /var/www/redmine_instance1/public

  <Location /requests>
    PassengerBaseURI /requests
    PassengerAppRoot /var/www/redmine_instance1
  </Location>

  <Directory /var/www/redmine_instance1/public>
    AllowOverride all
    Options -MultiViews
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName <myURL>/project

  DocumentRoot /var/www/

  RailsEnv production   

  Alias /project /var/www/redmine_instance2/public

  <Location /project>
    PassengerBaseURI /project
    PassengerAppRoot /var/www/redmine_instance2
  </Location>

  <Directory /var/www/redmine_instance2/public>
    AllowOverride all
    Options -MultiViews
  </Directory>

</VirtualHost>

Gitlab and Symfony3 on Debian8 Apache Server

I would like to use my ovh server at the same time for a Symfony3 site and a GitLab repository.

But now i have ony a 404 with GitLab fox icon on page and Symfony favicon :).

i have created 2 host conf.

symfony :

<VirtualHost *:80>
ServerName exemple.eu

DocumentRoot /var/www/dashboard/web
<Directory /var/www/dashboard/web>
    AllowOverride None
    Order Allow,Deny
    Allow from All

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
</Directory>

<Directory /var/www/dashboard/web/bundles>
    <IfModule mod_rewrite.c>
        RewriteEngine Off
    </IfModule>
</Directory>
ErrorLog /var/log/apache2/dashboard_error.log
CustomLog /var/log/apache2/dashboard_access.log combined

gitlab:

<VirtualHost *:80>
  ServerName gitlab.exemple.eu
  ServerSignature Off

  ProxyPreserveHost On

  <Location />
    Order deny,allow
    Allow from all

    ProxyPassReverse http://127.0.0.1:8080
    ProxyPassReverse http://gitlab.exemple.eu/
  </Location>

  RewriteEngine On
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]

  # needed for downloading attachments
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

</VirtualHost>

enter image description here

enter image description here

Thanks a lot for your help.

installing and configuring symfony 3.2

I am trying to install Symfony 3.2, I have tried to walk through the instructions here:

http://symfony.com/doc/current/setup.html.

first when running the command:

php.exe symfony new SymfonyProject

I got the error:

cURL error 60: SSL certificate problem: unable to get local issuer certificate

Which has a solution in here:

cURL error 60: SSL certificate: unable to get local issuer certificate

Afterward, I have installed and created a Symfony project successfully, I got an error page while trying to access http://localhost:port/config.php of my apache server.

so I headed to the apache configuration page:

http://symfony.com/doc/current/setup/web_server_configuration.html

and changed the minimum requirement variables to meet my system (off course a restart for the apache service is required):

<VirtualHost *:port>
    ServerName localhost
    ServerAlias localhost

    DocumentRoot "C:\xampp\htdocs\SymfonyProject\web"
    <Directory "C:\xampp\htdocs\SymfonyProject\web">
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    ErrorLog "C:\xampp\apache\logs\project_error.log"
    CustomLog "C:\xampp\apache\logs\project_access.log" combined
</VirtualHost>

I also changed Document root to "C:\xampp\htdocs\SymfonyProject\web" and tried also "C:\xampp\htdocs\SymfonyProject" (just in case) to no avail.

But am still getting an error:

Error from apache running Symfony project

project_access.log and project_error.log are empty.

I tried another page besides http://localhost:port/config.php

in here: http://symfony.com/doc/current/quick_tour/the_big_picture.html

it is being suggested that going to http://localhost:port/app/example is also a valid page, but I still get an error.

your help would be highly appreciated.

Apache2 blocking access to specific directory in root of server

I'm working on setting up a website and at first I thought the website was broken but then I look and I'm getting 403d on everything under /javascript/

I've double checked the filesystem permissions. I can rename the javascript folder to js and access the files just fine from a browser. I've tried finding all the locations where the site tries to access /javascript/ and change it to just /js/ but there are some other scripts running that are generating some script tags and it's not proving easy to find them all.

My question is, is there an easy(ish) way to find where apache may be hanging me up? It's a basic apache2 install on ubuntu 14.04 running in a digital ocean droplet.

How to add Apache module configuration directives?

How can I create configuration directives in apache2.conf file for my module or create separate configuration file for module configurations for these setting:

static const command_rec module_directives[] =
{
AP_INIT_FLAG("modsecurity", ap_set_flag_slot(void*)APR_OFFSETOF(apache_http_modsecurity_loc_conf_t,enable), OR_OPTIONS, "The argument must be either 'On' or 'Off'"),
AP_INIT_TAKE1("modsecurity_rules_file", ap_set_string_slot, (void*)APR_OFFSETOF(apache_http_modsecurity_loc_conf_t,rules_file), OR_OPTIONS, "Load ModSecurity rules from a file"),
AP_INIT_TAKE2("modsecurity_rules_remote", apache_http_modsecurity_set_remote_server, NULL, OR_OPTIONS, "Load ModSecurity rules from a remote server"),
AP_INIT_TAKE1("modsecurity_rules", ap_set_string_slot, (void*)APR_OFFSETOF(apache_http_modsecurity_loc_conf_t,rules), OR_OPTIONS, "Please ensure that the arugment is specified correctly, including line continuations."),
AP_INIT_FLAG("IOInput", enable_input, NULL, RSRC_CONF, "Enable Input Data"),
AP_INIT_FLAG("IOOutput", enable_output, NULL, RSRC_CONF, "Enable Output Data"),
{ NULL }
};

Apache: “AuthType not set!” 500 Error

It's been a while since I used the Apache httpd web server in windows. when I try to request localhost/index.html, I get a 500 error and I see this in the error log:

[client 127.0.0.1] configuration error: couldn't perform authentication. AuthType not set!: /

This line in my httpd.conf may be involved.

 <Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all granted
 </Directory>

my apache version is 2.2
OS : windows 7 how do I solve this 500 error?