Access Forbidden when using xampp with ngrok for accessing a local vhost - apache

I have set up a vhost that is working locally, I would like to access it from other devices using ngork. But I always get this message: "Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected." when trying to access the link provided by ngrok (although locally it works fine, and I even tried to disable my firewall altogether but the problem persisted)
My vhost:
NameVirtualHost *:80
<VirtualHost security.local:80>
ServerName security.local
ServerAlias security.local
DocumentRoot "E:\Websites\security\public"
<Directory "E:\Websites\security\public">
Order Allow,Deny
Options All
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
The ngrok command I use:
ngrok.exe http security.local
My hosts file:
127.0.0.1 security.local

I found the solution. The correct ngrok command has to be:
ngrok http -host-header=rewrite security.local

Related

Apache: 403 Forbidden when activate virtual host

i have an absurd problem with apache and CentOS, the webserver work in default mode, when go to http://myip i view correctly the apache test page. If add `/etc/httpd/conf.d/foo.conf
<VirtualHost *:80>
ServerName foo.local
DocumentRoot "/home/foo/html"
ErrorLog /var/log/httpd/foo.local-error.log
<Directory "/home/foo/html">
Options Includes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have 403 forbidden to ALL directory configured to apache, i do not see either the test page.
The directory /home/foo/html have owner and group apache, and permission 775 to directory and 664 to file. I see in the log:
AH00035: access to / denied (filesystem path '/home/foo/html') because search permissions are missing on a component of the path
If i deactive this conf file, apache works and see the test page
I have resolved changing the path, instead that /home/foo/html i put /var/www/foo and worked

Correct client denied by server configuration error after moving website to proxy

My website directory structure was this:
/var/services/web/
A portion of my website is a Wordpress page called portal with a Ninja Forms plugin. Ninja forms stores uploaded files in a directory on the server for all to see. So to deal with that I did this in the site's configuration file:
<Directory "/var/services/web/portal/wp-content/plugins/ninja-forms/">
AllowOverride None
Order deny,allow
Deny from all
</Directory>
I have had to move my website to a proxy server and now the Ninja Forms directory structure is like this:
/var/services/web/MYWEBSITE/portal/wp-content/plugins/ninja-forms/
I am not sure how to make the above Apache config item work in the proxy server. My proxy set up in httpd-ssl-vhost.conf-user is like this (port 80 is similar but I don't think that is an issue because I am only connecting ssl. Correct me if I am wrong):
<VirtualHost *:443>
ServerName www.MYWEBSITE.com
DocumentRoot "/var/services/web/MYWEBSITE"
ErrorDocument 403 "/webdefault/error.html"
ErrorDocument 404 "/webdefault/error.html"
ErrorDocument 500 "/webdefault/error.html"
SSLEngine on
</VirtualHost>
I tried just changing the path in the Apache config file to:
<Directory "/var/services/web/MYWEBSITE/portal/wp-content/plugins/ninja-forms/">
AllowOverride None
Order deny,allow
Deny from all
</Directory>
And this just produces the following error:
client denied by server configuration: /var/services/web/MYWEBSITE/portal/wp-content/plugins/ninja-forms . . . etc.
So, I think I need to add lines to my proxy ssl set up. I could use tips on the proper SSL set up in my proxy server. Other solutions I have found here appear to be changing the Deny from All line and I do not want that.

How to route all *.dev to subfolders on vagrant box

I want that every *.dev Host will be routed to my vagrant machine to /var/www/vhosts/*.dev/public, for example my local development environment project1.dev is located in /var/www/vhosts/project1.dev/public
So when I add a new (sub)project into my box, I do not need to change my config.yaml (Vagrant installed via puphpet.com) and reload the machine.
On my computer, I added the following to the hosts file in /private/etc:
192.168.56.101 *.dev
On my VM, I changed my 10-default_vhosts80.conf in /etc/apache2/sites-enabled to:
# ************************************
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************
<VirtualHost *:80>
ServerName default
## Vhost docroot
DocumentRoot "/var/www/default"
## Directories, there should at least be a declaration for /var/www/default
<Directory "/var/www/default">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
## Load additional static includes
## Logging
ErrorLog "/var/log/apache2/default_vhost_80_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/default_vhost_80_access.log" combined
## Custom fragment
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/default/$1
</VirtualHost>
<VirtualHost *.dev:80>
ServerName dev
VirtualDocumentRoot /var/www/vhosts/%0
</VirtualHost>
Unfortunately, this doesn't work. Any ideas? I am a beginner in this subject.
I use a proxy auto configuration file. This works on Windows, MacOS and Linux. Easy, flexible and no additional software required. The following example routes all *.dev traffic to your vagrant box:
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".dev")) {
return "PROXY 127.0.0.1:8080";
}
return 'DIRECT';
}
When needed, replace 127.0.0.1:8080 with the IP and webserver port of your vagrant box. Store this file somewhere. You can store it locally or let the webserver on your Vagrant-box host the file.
Windows: See here how to use the PAC file on Windows.
MacOS: See here how to use the PAC file on MacOS. You can link to the file using file:///Users/username/path/to/proxy.pac.
Linux: For linux it depends, but I'm sure linux users will be able to Google for their specific situation.
Unfortunately hosts files do not support using wildcards. You have to manually define each and every host to redirect.
Also, your hosts file is at /etc/hosts
In the end, I use dnsmasq to route all .localdev Domains to 127.0.0.1. Note that I am using .localdev instead of just .dev or .local as this seems to cause problem (OS X 10.10) because .dev is a proposed gTLD and .local is used by Apple's Bonjour.
Then I configured Apache by creating and enabling this site:
<VirtualHost *:80>
ServerAlias localhost *.localdev #wildcard catch all
VirtualDocumentRoot /hosts/%1/public
UseCanonicalName Off
<Directory "hosts">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(from: http://brunodbo.ca/blog/2013/04/26/setting-up-wildcard-apache-virtual-host-wildcard-dns)

vhosts dont appear to be working on OS X Mavericks Apache installation

I am trying to set up the Apache server which comes with OS X Mavericks with vhosts so that a domain name resolves to my user level document webroot. I have followed this tutorial which guided me through setting up the apache server with php:
http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-9-mavericks/
as well as this one which guided me through setting up the vhosts:
http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-9-mavericks-osx-10-8-mountain-lion/
Following these tutorials, if I type localhost in my browser it correctly resolves to the system level root (/Library/WebServer/Documents/ folder). If I use localhost/~myusername it correctly resolves to my user level root (/users/myusername/Sites/).
However, whenever I navigate to my domain, I get redirected to the system level root rather than my user level root.
My vhosts file reads as follows:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "/Users/myusername/Sites/mydomain"
<Directory "/Users/myusername/Sites/mydomain">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Any ideas?
Have you enabled Virtualhosts?
NameVirtualHost *:80
And included your vhosts directory
Include <path>/vhosts/*
On a Macbook, you may need to include /private/ at the beginning of any absolute path, so that Apache can read it correctly off the file system.
For others who have the same problem...
It was frustratingly simple - I had missed the "" around the localhost directory.
How annoying!
Try starting apache manually with the -S option to see what the problem might be:
/usr/sbin/httpd -S

Adding VirtualHost breaks all other server folders

I am trying to run designer-school.com on my server. I have added this VirtualHost
<VirtualHost *:80>
DocumentRoot /var/www/html/backendtwo
ServerName www.designer-school.com
<Directory /var/www/html/backendtwo>
Allow from all
Options +Indexes
</Directory>
</VirtualHost>
This now means I can access the domain designer-school.com
But if i try and access other folders on this server I get 404 errors for example
http://joshhornby.co.uk/typewriter
And also If i try and access a blog post on the root website
http://joshhornby.co.uk/post/web-course
Is there a way to run the domain designer-school on the server but it won't impact the other sites running on the server?
I have looked at running multiple VirtualHosts must when I restart the server I get this message
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
Is there something in my .haccess file I need to change?