issue with shibboleth SP in docker container behind proxy - php

I am trying to get a shibboleth set up working in a docker container behind a proxy.
Currently I am able to get redirected to the shibboleth idp page where I can enter my login details and shibboleth will authenticate me. It is failing with a 404 when it attempts to redirect back to: https://my-service.org/Shibboleth.sso/SAML2/POST
I can't tell if this is an apache issue or something with the shibboleth config.
There is a server with apache and docker running on it. The apache here is proxying traffic to the docker containers running on the same server. I have dns point a domain name to the proxy. Lets call it "my-service.org". The apache proxy config for my-service.org is as follows:
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName my-service.org
ServerAdmin devs#blah.org
DocumentRoot /var/www/html/my-service
Redirect permanent / https://my-service.org/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost _default_:443>
ServerName my-service.org
ServerAdmin devs#blah.org
DocumentRoot /var/www/html/my-service
ErrorLog ${APACHE_LOG_DIR}/docker-dev/my-service.log
CustomLog ${APACHE_LOG_DIR}/docker-dev/my-service_ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/blah.crt
SSLCertificateKeyFile /etc/ssl/private/blah.key
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
SSLProtocol All -SSLv2 -SSLv3
SSLCompression off
SSLHonorCipherOrder on
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
RequestHeader set X-Forwarded-SSL expr=%{HTTPS}
ProxyPass / http://127.0.0.1:8088/
ProxyPassReverse / http://127.0.0.1:8088/
</VirtualHost>
</IfModule>
The 'my-service' container is based on the 'php:7-apache-buster' container and is running apache with shibd. It is part of a docker-compose stack. The apache config of the container is:
<VirtualHost *:80>
ServerAdmin me#blah.org
DocumentRoot /var/www/html/my-service
<Directory /var/www/html/my-service/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Location "/shibboleth_login.php">
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUseHeaders On
require valid-user
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Like I said everything is working up until the point of redirection back from the shibboleth idp to the SP, where it 404s. The logs are not telling me much but there is an error log when I load the containers apache config:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.6. Set the 'ServerName' directive globally to suppress this message
I am not sure if this would have an affect of the situation.
One thing I thought may have an affect is the fact that I have shibboleth set to handle SSL:
<Sessions lifetime="28800" timeout="3600" relayState="ss:mem"
checkAddress="false" handlerSSL="true" cookieProps="https">
But my container apache config only defines a HTTP virtual host block. As you can see the proxy passes the protocol to the container via the X-Forwarded-Proto and X-Forwarded-SSL headers. I needed those for the 'my-service' php app but not sure if they have an affect on shibboleth. The initial interaction with the idp works fine, its just the redirection back that doesn't work.

I figured out that I needed to add a ServerName attribute as follows:
<VirtualHost *:80>
ServerAdmin me#blah.org
DocumentRoot /var/www/html/my-service
ServerName https://my-service.org:443
UseCanonicalName On
<Directory /var/www/html/my-service/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Location "/shibboleth_login.php">
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUseHeaders On
require valid-user
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Related

How to set by api to use HTTPS (error net::ERR_SSL_PROTOCOL_ERROR)

I have setup my frontend an my backend with apache and both worked with http. The front end (react) is setup on port 80 with a virtual host (see below) and the api (php) is using port 8080 with a virtual host too. The folder structure is having my backend and front end in the same root projet folder:
-folder
-frontend
-build folder
-rest-api-authentification
-api folder
I setup my domain xxxx.ca with cerbot and my frontend is working on https://xxxx.ca. But now it's my api that I can't seems to make work. I can call the api alone with postman at http://xxxx.ca/api/test.php and it works. Same when using curl http://xxxx.ca/api/test.php on the server.
What is the config that is missing to use my api in https (the way is needs to be called is https://xxxx.ca/api/test.php).
Do I need another certificate for my api event if it's on the same domain but using the port 8080? I Tried to use a proxy to redirect calls from the /api without success.
Thanks!
Here are the virtual hosts that i have setup
domain#react.conf
<VirtualHost *:80>
DocumentRoot "/mnt/example/frontend/build"
ServerName xxxx.ca
ServerAlias www.xxxx.ca
<Directory "/mnt/example/frontend/build">
AllowOverride All
Require all granted
</Directory>
SSLCertificateFile /etc/letsencrypt/live/xxxx.ca/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx.ca/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
domain#react-le-ssl.conf (auto-generated)
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot "/mnt/example/frontend/build"
ServerName xxxx.ca
ServerAlias www.xxxx.ca
<Directory "/mnt/example/frontend/build">
AllowOverride All
Require all granted
</Directory>
#I added this section as a test
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:8080/api
ProxyPassReverse / http://127.0.0.1:8080/api
SSLCertificateFile /etc/letsencrypt/live/xxxx.ca/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx.ca/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
domain#api.conf
<VirtualHost *:8080>
DocumentRoot "/mnt/example/rest-api-authentication"
ServerName xxxx.ca
ServerAlias www.xxxx.ca
<Directory "/mnt/example/rest-api-authentication">
AllowOverride None
Require all granted
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>

How to match dynamic sub-domain alias to sub-folder on apache server

I am currently developing a SaaS web based project using PHP which requires users to have unique sub-domains to use the application.
I am done configuring the server with wildcards: Eg. user.example.com ==> *.example.com. The application creates a subfolder for the user under /var/www/html/ with the name of the user Eg. user.example.com would be in /var/www/html/user/.
I am stuck on getting the user's link without the base folder such as user.example.com to point to /var/www/html/user/ without having to include http://user.example.com/user.
I have tried virtual host and aliases but it seems like I have to manually assign the variable which is not applicable for the project.
I just need the subdomains to point to their respective subfolders.
My apache config file
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin admin#xxxxxxx.tdl
DocumentRoot /var/www/html/%1/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
ErrorDocument 404 /error_404.html
</VirtualHost>
Finally after researching I got a solution. I realised that I had not activate the alias module and so I activated as follows:
sudo a2enmod vhost_alias
I also noted that serving each sub-domain to its respective sub-folder required a dynamic config script to auto-pick the VirtualDocumentRoot through Directory Name Interpolation as follows:
<VirtualHost *:80>
ServerAdmin admin#vspace.ke
DocumentRoot /var/www/html/
VirtualDocumentRoot /var/www/html/%1/
<Directory "/var/www/html/">
Options FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
I also noted that you have to declare all sub-domains and non sub domain in the host configurations:
I.E
Alias for www
<VirtualHost *:80>
ServerName www.vspace.ke
ServerAlias www
DocumentRoot /var/www/html/
<Directory /var/www/html/>
Options +FollowSymLinks
</Directory>
</VirtualHost>
Alias for no sub-domain
<VirtualHost *:80>
ServerName vspace.ke
ServerAlias
DocumentRoot /var/www/html/
<Directory /var/www/html/>
Options +FollowSymLinks
</Directory>
</VirtualHost>
And * (wild card) sub-domain
<VirtualHost *:80>
ServerAdmin admin#vspace.ke
DocumentRoot /var/www/html/
VirtualDocumentRoot /var/www/html/%1/
<Directory "/var/www/html/">
Options FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
Thank you so much for contributing.

Codeigniter redirect points to wrong address

I use codeigniter and this is my redirecting function:
$this->load->helper('url');
redirect(base_url('main'));
It works properly when I am trying on my PC where the webserver is running but when I am connecting to my computer's webserver from another device then this points to localhost.
What am I doing wrong?
In order to have a correct relation passes you need to configure your virtual host:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
ErrorLog "c:/wamp/logs/apache_error.log"
CustomLog "c:/wamp/logs/access.log" common
</VirtualHost>
<VirtualHost 192.168.1.2:80 127.0.0.1:80>
DocumentRoot "D:/SVN/joomla/"
ServerName joomla
ErrorLog "c:/wamp/logs/joomla_error.log"
CustomLog "c:/wamp/logs/joomla_access.log" common
<Directory "D:/SVN/joomla/">
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
So your project will be available via local net by IP 192.168.1.2
So you will write http://192.168.1.2/myproj
Also in a httpd.conf
Listen 127.0.0.1:80 192.168.1.2:80

How to setup 2 domain on one XAMPP server on the same port?

I have two different PHP application running on XAMPP server.
I need to be able to access both application using two different domain.
The first application will be local to the server "dev.app".
The second app will be accessible from the internal network "staging.domain.com"
The internal IP for the server is 10.0.4.18.
In the httpd.conf I added the following line to run XAMPP on 10.0.4.18
Listen 10.0.4.18:80
Additionally, in the httpd-vhosts.conf I added the following code
#Staging
<VirtualHost *:443>
DocumentRoot "F:/xampp/htdocs/staging"
ServerAdmin mikea#domain.com
ServerName staging.domain.com
ServerAlias staging.domain.com
SSLEngine On
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
<Directory "F:/xampp/htdocs/staging">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
#dev
<VirtualHost *:443>
DocumentRoot "F:/xampp/htdocs/dev/public"
ServerAdmin mikea#domain.com
ServerName dev.app
ServerAlias dev.app
SSLEngine On
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
<Directory "F:/xampp/htdocs/dev/public">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
My hosts file looks like this
127.0.0.1 localhost
127.0.0.1 127.0.0.1
10.0.4.18 dev.app
However, when I open "dev.app" from the local server's browser, it redirects me to staging.domain.com.
How can I be able to access both domain without interfering?

how to create virtual host on XAMPP [duplicate]

This question already has answers here:
How To Set Up Apache Virtual Hosts on XAMPP (Windows) [closed]
(4 answers)
Closed 1 year ago.
I am sure this question is being asked many times but I am not encounter with a problem. I am using XAMPP where I configure Zend framework.
XAMPP is running on port 8081 as 80 is being occupied by some Windows process I need to use virtual host for that I configure with following code in C:/xampp/apache/config/extra/httpd-vhosts.config (or C:/xampp/apache/conf/extra/httpd-vhosts.conf in newer releases).
<VirtualHost *:80>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public"
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and also update the hosts file with 127.0.0.1 comm-app.local and try to re-start apache but it is showing error.
15:03:01 [Apache] Error: Apache shutdown unexpectedly.
15:03:01 [Apache] This may be due to a blocked port, missing dependencies,
15:03:01 [Apache] improper privileges, a crash, or a shutdown by another method.
15:03:01 [Apache] Press the Logs button to view error logs and check
15:03:01 [Apache] the Windows Event Viewer for more clues
15:03:01 [Apache] If you need more help, copy and post this
15:03:01 [Apache] entire log window on the forums
Step 1) C:\WINDOWS\system32\drivers\etc\
Open the "hosts" file :
127.0.0.1 localhost
127.0.0.1 test.com
127.0.0.1 example.com
Step 2) xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/test/
ServerName www.test.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/example/
ServerName www.example.com
</VirtualHost>
Step 3) C:\xampp\apache\conf\httpd.conf. Scroll down to the Supplemental configuration section at the end, and locate the following section (around line 500), Remove the # from the beginning of the second line so the section now looks like this:
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
Step 4) Restart XAMPP
and now run in your browser :
www.example.com or www.test.com
I see two errors:
<VirtualHost *:80> -> Fix to :8081, your POrt the server runs on
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public" -> This is probably why it crashes, missing >
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
-> MIssing close container: </VirtualHost>
Fixed version:
<VirtualHost *:8081>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
One thing to mention:
You can always try and run command:
service apache2 configtest
This will tell you when you got a malformed configuration and maybe even can tell you where the problem is.
Furthermore it helps avoid unavailability in a LIVE system:
service apache2 restart
will shutdown and then fail to start, this configtest you know beforehand "oops I did something wrong, I should fix this first" but the apache itself is still running with old configuration. :)
Add this Code in C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName qa-staging.com
ServerAlias www.qa-staging.com
<Directory "c:/xampp/htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now Add your virtual host name in bellow file.
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 qa-staging.com
If you are not able to save this code in host file then right click on notpad select Run as administrator and then you can able to save your custom code now restart your XAMP
Write these codes end of the C:\xampp\apache\conf\extra\httpd-vhosts.conf file,
DocumentRoot "D:/xampp/htdocs/foldername"
ServerName www.siteurl.com
ServerAlias www.siteurl.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
between the virtual host tag.
and edit the file System32/Drivers/etc/hosts use notepad as administrator
add bottom of the file
127.0.0.1 www.siteurl.com
<VirtualHost *:80>
DocumentRoot "D:/projects/yourdirectry name"
ServerName local.yourdomain.com
<Directory "D:/projects/yourdirectry name">
Require all granted
</Directory>
</VirtualHost>
Save the Apache configuration file.
for detailed info refer to this
Just change the port to 8081 and following virtual host will work:
<VirtualHost *:8081>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In Your disk drive:\xampp\apache\conf\extra\httpd-vhosts.conf exists an example and you could edit it with your configuration:
##<VirtualHost *:80>
##ServerAdmin webmaster#dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>
It would be like this, as example and don't forget to add VirtualHost for localhost itself to have posibility run phpmyadmin and other project at the same time on the port 80, as example I will show with store.local project:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#store.local
DocumentRoot "c:/xampp/htdocs/store.local/public"
ServerName www.store.local
ServerAlias store.local
<Directory C:/xampp/htdocs/store.local>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
then as mentioned above you must add in:
C:\windows\system32\drivers\hosts to the bottom of the file
127.0.0.1 store.local
127.0.0.1 www.store.local
restart Apache and try in the browser:
store.local or www.store.local
maybe at the first time you must to add like this:
http://store.local or http://www.store.local
to use other ports, you must add follows, before your VirtualHost:
Listen 8081 or another which you prefer
then just use the port for your VirtualHost like this:
<VirtualHost *:8081>
ServerAdmin webmaster#store.local
DocumentRoot "c:/xampp/htdocs/store.local/public"
ServerName store.local
ServerAlias www.store.local
<Directory C:/xampp/htdocs/store.local>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
then restart Apache and try in the browser
store.local:8081 or www.store.local:8081
and only project for which you add the port will running on this port, for example other projects and phpmyadmin will be still running on port 80
Apache Virtual Host documentation Setting up a virtual host (vhost) provides several benefits:
Virtual Hosts make URLs cleaner – localhost/mysite vs mysite.local.
Virtual Hosts make permissions easier – restrict access for a single vhost on a local network vs permitting access to all sites on your local network.
Some applications require a “.” in the URL (ahem Magento). While you can setup localhost.com/mysite by editing the Windows hosts file, creating a vhost is a better solution.
VirtualHost Directive Contains directives that apply only to a specific hostname or IP address
Location Directive Applies the enclosed directives only to matching URLs
Example changes over configuration file - D:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin localhost
DocumentRoot "D:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost localhost:80>
ServerAdmin webmaster#host.example.com
DocumentRoot "/www/docs/host.example.com"
#DocumentRoot "D:\xampp\htdocs\phpPages"
ServerName host.example.com
ErrorLog "logs/host.example.com-error_log"
TransferLog "logs/host.example.com-access_log"
</VirtualHost>
# To get view of PHP application in the Browser.
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host.localhost
DocumentRoot "D:\xampp\htdocs\app1"
ServerName app1.yash.com
ServerAlias app1.yash.com
ErrorLog "logs/app1.yash.com-error.log"
CustomLog "logs/app1.yash.com-access.log" combined
# App1 communication proxy call to Java War applications from XAMP
<Location /ServletApp1>
ProxyPass http://app1.yashJava.com:8080/ServletApp1
ProxyPassReverse http://app1.yashJava.com:8080/ServletApp1
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin postmaster#infotreesolutions.com
DocumentRoot "D:\xampp\htdocs\app2"
ServerName app2.yash.com
ErrorLog "logs/app2.yash.com-error.log"
CustomLog "logs/app2.yash.com-access.log" combined
# App1 communication proxy call to Java War applications from XAMP
<Location /ServletApp2>
ProxyPass http://app1.yashJava.com:8080/ServletApp2
ProxyPassReverse http://app1.yashJava.com:8080/ServletApp2
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>
Update Your Windows Hosts File « Open your Windows hosts file located in C:\Windows\System32\drivers\etc\hosts.
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 test.com
127.0.0.1 example.com
127.0.0.1 myssl.yash.com
D:\xampp\apache\conf\httpd.conf, [httpd-ssl.conf](http://httpd.apache.org/docs/2.2/mod/mod_ssl.html)
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost> directive.
# Listen 0.0.0.0:80 | [::]:80
Listen 80
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule speling_module modules/mod_speling.so
# ServerAdmin: Your address, where problems with the server should be e-mailed.
# This address appears on some server-generated pages, such as error documents.
# e.g. admin#your-domain.com
ServerAdmin postmaster#localhost
ServerName localhost:80
DocumentRoot "D:/xampp/htdocs"
<Directory "D:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"
# ===== httpd-ssl.conf - SSL Virtual Host Context =====
# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two
# Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"
Listen 443
## SSL Virtual Host Context
<VirtualHost _default_:443>
DocumentRoot "D:\xampp\htdocs\projectFolderSSL"
ServerName myssl.yash.com:443
ServerAlias myssl.yash.com:443
ServerAdmin webmaster#localhost
ErrorLog "logs/error.log"
<IfModule log_config_module>
CustomLog "logs/access.log" combined
</IfModule>
## Redirecting URL from Web server to Application server over different machine.
# myssl.yash.com:443/ServletWebApp
<Location /path>
ProxyPass http://java.yash2.com:8444/ServletWebApp
ProxyPassReverse http://java.yash2.com:8444/ServletWebApp
Order Allow,Deny
Allow from all
</Location>
#SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateFile "D:\SSL_Vendor\yash.crt"
#SSLCertificateKeyFile "conf/ssl.key/server.key"
SSLCertificateKeyFile "D:\SSL_Vendor\private-key.key"
#SSLCertificateChainFile "conf/ssl.crt/server-ca.crt"
SSLCertificateChainFile "D:\SSL_Vendor\intermediate.crt"
</VirtualHost>
# ===== httpd-ssl.conf - SSL Virtual Host Context =====
#see
XAMPP security concept - Error 403,404
Apache VirtualHost and localhost
I fixed it using following configuration.
Listen 85
<VirtualHost *:85>
DocumentRoot "C:/xampp/htdocs/LaraBlog/public"
<Directory "C:/xampp/htdocs/CommunicationApp/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I'm a little late to the party, but I wrote this little bash script for Mac that creates a VirtualHost through the terminal:
#!/bin/bash
echo "Welcome to the VirtualHostCreator! Press <RETURN> to continue."
read
echo "Enter the name the VirtualHost you would like to create. No spaces or dashes, please."
read hostname
echo "Enter the document root of the VirtualHost."
read doc_root
echo "Creating VirtualHost \"$hostname\". You may be prompted for your password."
hosts_file="/etc/hosts"
vhosts_file="/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf"
restart_command="sudo /Applications/XAMPP/xamppfiles/xampp restart"
cat >> $vhosts_file << EndOfMessage
<VirtualHost ${hostname}>
ServerName ${hostname}
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/${doc_root}"
</VirtualHost>
EndOfMessage
sudo sh -c "echo \"127.0.0.1 $hostname\" >> $hosts_file"
$restart_command
I'm sure there are a few improvements that can be made, and it only has the two required options for the vhost (server name and document root), but it does the job much more quickly and efficiently than opening and editing all the files manually, and also automatically restarts XAMPP afterwards.
This assumes that you have the default installation location for XAMPP, which can all be changed.
Step 1) Open Host File Under "C:\Windows\System32\drivers\etc"
Add
127.0.0.1 vipsnum.mk
Step 2) Open httpd-vhosts.conf File Under "C:\xampp\apache\conf\extra"
Add
<VirtualHost vipsnum.mk:80>
ServerName vipsnum.mk
DocumentRoot "C:/xampp/htdocs/vipnum/"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/vipnum/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
1. C:\xampp\apache\conf\https.conf
Virtual hosts
Include conf/extra/httpd-vhosts.conf
2. C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 helpdesk.local
3. C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/helpdesk/public"
ServerName helpdesk.local
</VirtualHost>
Now, Restart Apache and go through the link.
URL : http://helpdesk.local
Problem with xampp in my case is when specifying a different folder other than htdocs are used, especially with multiple domains and dedicated folders. This is because httpd-ssl.conf is also referencing <VirtualHost>.
To do this rem out the entire <VirtualHost> entry under httpd-ssl.conf
From there, any setting you do in your httpd-vhosts.conf will update as expected both http and https references.
I have been looking for the solution for quite a bit. And finally I have the answer. If your virtual host is not working on your Windows 10, or 7 etc, it's because of this new https hype, where all the sites are routed to https.
XAMPP follows the same trend, so fixing virtual hosts, hosts file etc is not enough, due to strict https redirection. Here is the full solution.
My desired site is located at D:\xampp\htdocs\ikeen.
1) Add this to your httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ikeen.localhost
DocumentRoot "D:\xampp\htdocs\ikeen"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\ikeen">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2) Add this to the end of httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
3) Add this line to your hosts file in Windows directory
127.0.0.1 ikeen.localhost
4) The final step is to change the VirtualHost section of your httpd-ssl.conf file to the following
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "D:/xampp/htdocs"
#ServerName www.example.com:443
ServerName localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
# General setup for the ikeen host
DocumentRoot "D:/xampp/htdocs/ikeen"
#ServerName www.example.com:443
ServerName ikeen.localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
Restart and be happy:)
I have added below configuration to the httpd.conf and restarted the lampp service and it started working. Thanks to all the above posts, which helped me to resolve issues one by one.
Listen 8080
<VirtualHost *:8080>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName localhost:8080
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory "/opt/lampp/docs/dummy-host2.example.com">
Require all granted
</Directory>
</VirtualHost>
Simple,
You can see the below template and use it accordingly. Its very common to create a virtual host and very simple. Surely below template will work.
<VirtualHost *:8081>
DocumentRoot "C:/xampp/htdocs/testsite"
ServerName testsite.loc
ServerAlias www.testsite.loc
<Directory "c:/xampp/htdocs/testsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Also for more reference about virtual host please visit this site.
http://www.thegeekstuff.com/2011/07/apache-virtual-host
Thanks,

Categories