Virtual host on WAMP server works for Firefox only - browser

I have installed WAMP Server and added virtual host.
Strange thing:
On Firefox (my default browser) everything works ok.
On other browsers (Chrome, IE, Opera) the localhost is ok. I can run
php files in default directory/subdirectories, phpMyAdmin works ok as
well. But virtual host is not accessible (error
DNS_PROBE_FINISHED_NXDOMAIN or DNS_PROBE_FINISHED_BAD_CONFIG - see comments in hosts file).
Can you help me to find, why virtual hosts does not work on other browsers than default Firefox?
I am not experienced in this stuff, so it is possible that I do some very basic mistake.
More details:
I run WAMP Server 3.2.6 (64 bit) on Windows 10
I use port 8080 because of some
port conflict (probably Skype)
Adding Virtual Host via WAMP was
"easy", but I have to modify host file (port 8080 was missing).
Windows hosts file:
127.0.0.1 localhost
# with line "127.0.0.1 localhost" browser returns DNS_PROBE_FINISHED_NXDOMAIN
# without line "127.0.0.1 localhost" browser returns DNS_PROBE_FINISHED_BAD_CONFIG
127.0.0.1 localhost:8080
::1 localhost
127.0.0.1 sb:8080
::1 sb
httpd-vhosts.conf file:
# Virtual Hosts
NameVirtualHost *.8080
<VirtualHost *:8080>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName sb
DocumentRoot "d:/weby/sb/www/"
<Directory "d:/weby/sb/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

Related

Running Traefik docker-proxy behind an apache server, redirecting/proxying some of the requests (or vice versa)

I have a Traefik-2 docker-compose-setup for dev (and one similar for prod) with multiple docker-compose projects containing multiple dc-images, each can be reached locally like this: https://docker-app1.docker-doamin1.loc, incl. HTTPS/SSL-Certs; "dns" via /etc/hosts.
This works like a charm, when the traefik-container is running and the apache is not (port conflict otherwise)
I also have some projects that can be run directly on a local apache (on ubuntu/debian) with configurations in /etc/apache2/sites-available/ like this:
<VirtualHost *:80>
ServerName apache-app1.apache-domain1.loc
DocumentRoot /path-to/apache-app1.apache-domain1.loc/public
<Directory /path-to/apache-app1.apache-domain1.loc/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
Fallbackresource /index.php
</Directory>
DirectoryIndex index.php index.html
</VirtualHost>
But only if the apache is running and the docker-traefik container ist not, again because of the conflicting 80/443
I need (or want) both Versions to run simultaneously.
My idea was to run the docker-traefik container on different ports (20080/20443) and redirect/ProxyPass from apache to that docker-proxy-container (the other way round would be okay too)
I tried (e.g.)this:
<VirtualHost *:443>
ProxyPreserveHost On
ProxyRequests Off
ServerName docker-app1.docker-doamin1.loc
ServerAlias www.https://docker-app1.docker-doamin1.loc
ProxyPass / https://docker-app1.docker-doamin1.loc:20443/
ProxyPassReverse / https://docker-app1.docker-doamin1.loc:20443/
</VirtualHost>
having
127.0.1.1 docker-app1.docker-doamin1.loc
in my /etc/hosts.
But it does not work. And it would be better in each case to have wildcards redirected like this: *.docker-doamin1.loc.
For now all of this is for a local dev environment, so security is not that relevant.
It would be great, if someone had some hints here.

/etc/hosts configuration not being detected

Am configuring a local linux development environment utilizing apache, i can access the url:
http://localhost:8080
but not the configured virtualhost entries which are also present in the /etc/hosts file e.g if i enter:
http://admin:8080
in my browser redirects me to www.admin.com, which is an external address.
/etc/hosts file has the following entries:
127.0.0.1 localhost admin jobboard
127.0.1.1 rob-VirtualBox
Apache config(virtual hosts reference the above entries admin and jobboard):
Listen 8080
Port 8080
ServerName 127.0.0.1:8080
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts"
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts">
NameVirtualHost *:8080
<VirtualHost 127.0.0.1:8080>
ServerName admin
# set the document root
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts/Client-asap.bigredsky.com"
# set the directory settings
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts/Client-asap.bigredsky.com">
Options All Includes Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
ServerName jobboard
# set the document root
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts/JobBoard-asapdev.bigredsky.com"
# set the directory settings
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts/JobBoard-asapdev.bigredsky.com">
Options All Includes Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Apache and Computer was restarted after changes to config files were saved.
Is their some other hosts configuration file which needs to be modified? Running linux mint OS.
Thanks in advance.
in the virtual host config try this for admin
ServerAlias admin
that should resolve the admin website to local server
furthermore check whether you are under any proxy...you should turn it off...
create one more vhost entry for admin
<VirtualHost 127.0.0.1:8080>
ServerName admin

virtualhost without real domain name

I've this configuration for my virtual host and runs with real domains. For testing purpose I need create same virtual host with non real domain (i.e. domain10). Considerated that the browser check the name of domain of virtual host, I think using something like 127.0.0.1. But I've no idea to realize this.
<VirtualHost *:80>
ServerAdmin info#domain10.org
ServerName domain10.org
ServerAlias domain10.org
DirectoryIndex index.html index.htm index.php
DocumentRoot /home/domain10.org/
<Directory /home/domain10.org/>
Options -Includes -Indexes -FollowSymLinks -ExecCGI +MultiViews
AllowOverride none
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You can use the /etc/hosts file for this purpose. There should already be a line in it beginning with 127.0.0.1. Just add domain10.org to the list of hosts that resolves to this address.
For example, if the existing line is:
127.0.0.1 localhost localhost.localdomain
Just extend it to:
127.0.0.1 localhost localhost.localdomain domain10.org
Then (on this machine only) domain10.org will resolve to 127.0.0.1. If you are testing on the same machine, you can enter http://domain10.org/ in your browser to reach your local web server.
If you need to reach this host over the Internet, then a different approach is needed. Look for a line for the external IP address of the server in its /etc/hosts file and modify it similar to the above instructions. If such a line does not exist, add one.
On the client machine, do the same (using /etc/hosts for a Linux box or %WINDIR%\system32\drivers\etc\hosts for a Windows box). You should then be able to reach the server from the client using this name.

Resolving virtual hosts apache 2

I'm trying to setup my apache server to access certain folders when I type addresses like test1.example.com test2.example.com etc.
So far I read and did many things but with no success yet. I'll be very thankful if you can help me.
So to start I'm using ubuntu 12.10 as my desktop and I've set up apache server there. I've added example.com in hosts resolving to 127.0.0.1. So far no problems. I've enable vhost_alias and mod_rewrite in apache and I'm using this for my virtual server
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?([^\.]+).example.com$
RewriteRule ^(.*) $1 [F]
VirtualDocumentRoot /home/example/server/projects/%1/public_html
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/radoslav/server/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#log file for this server
CustomLog /var/log/apache2/example.com.log combined
</VirtualHost>
But when I open test.example.com it says that browser can find test.example.com, no matter that I have this directory in the path specified. Just to clear things up apache have permissions to read this directory so it's not this. When I ping example.com from console I get ping but if I ping test.example.com I get error that can not find host. As you can see obviously it's not resolving the adress no matter that I've setup everything correcly.
Any help guys?
You need to add test.example.com and any other hostnames you want to use in the host file. The host file does not supports wildcard.

How do I set up my hosts and httpd.conf files using a static IP address

I set Centos 6.3 up on a Rackspace box, using a static IP address (not a FQDN). I will be setting up virtual hosts on this box, and it seems to be working fine, but when I restart the HTTPD server, I get an error message "could not reliably determine the server's fully qualified domain name, using xx.xxx.xx.xx for ServerName" (xx.xxx.xx.xx is the static IP address for the server).
My /etc/hosts has the following in it:
27.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
xx.xxx.xx.xx name-used-for-rackspace
name-used-for-racspace is a name (not a FQDN) I used when I created the server (you have to enter a name).
I assume that I may not have to change anything in /etc/hosts, but what do I put in httpd.conf? right now, I have the following in that file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
<Directory /var/www/html>
allow from all
Options +Indexes
</Directory>
</VirtualHost>
I also tried setting ServerName to xx.xxx.xx.xx, but I got the same error message.
This error is because you are not using a FQDN. It should not affect the operation of the webserver.
To get rid of the message on startup you'd need to configure your hosts file with the correct domain and IP address. Your httpd.conf should also use the same name (where you have localhost specified).
As long as your server is starting and you don't plan on assigning a domain to your webserver, this error can be ignored.
Example virtual host with FQDN:
<VirtualHost *:80>
ServerName www.domain.net
ServerAlias domain.net *.domain.net
ServerAdmin administrator#domain.net
DocumentRoot "/home/domain/htdocs"
<Directory "/home/domain/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
CustomLog "/home/domain/logs/access-www.log" common
ErrorLog "/home/domain/logs/error-www.log"
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
Example hosts file:
127.0.0.1 localhost localhost.localdomain gentoo1
x.x.x.x gentoo1.domain.net
You need to configure the network connection with your static IP, see reference below. Otherwise, your web server is working, but it's not accessible externally.
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_IPv4_Settings.html
Then put the static IP in the httpd.conf after server name.

Resources