Can't access apache2 virtualhost from another computer [closed] - apache

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am running an apache2 webserver from my computer and when I access the site from my computer,
it works just fine, but when I try to access it from another machine(that runs windows), the browser outputs, that the site can't be reached.
Here is my site config file:
<VirtualHost 192.168.1.96>
# 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 webmaster#localhost
DocumentRoot /var/www/example
ServerName www.example.com
# 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
</VirtualHost>
Here is my /etc/hosts file
127.0.0.1 localhost
127.0.1.1 puter
127.0.1.1 noreply.com
192.168.1.96 www.vk1.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I have tried restarting apache and disabling and enabling the site, but that didn't work.
Has anyone encountered such problems before?

The /etc/hosts file provides host to IP address mappings for the computer it lives on.
Your Windows computer is not going to read the data from your Linux computer's /etc/hosts file in order to know that it needs to make requests to 192.168.1.96 when it is asked to make a request to www.vk1.com.
You need to either:
Configure that mapping in the DNS server for your LAN
Put that information in the hosts file on the Windows computer

Related

Subdomain Apache2

its the first time I try to host a website.. First i bought an domain on "Strato" and I got apache running on this domain via a ubuntu server and our fitzbox using Dyndns. But now i want to do the next step and host a subdomain. I created a subdomain on the strato web interface and tryed to set it up in apache, but i can't connect to it. If i change the DynDns in our fritzbox to the subdomain i can connect to the subdomain but not to the normal Domain, u know what i can do to reach both of them via the internet?
In apache I created this 2 files: 000.default.conf ---- both of them are enabled
<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.SaneQt.de
ServerAdmin webmaster#localhost
DocumentRoot /var/www/000
# 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
</VirtualHost>
001-oneway.conf
<VirtualHost *:80>
ServerName onewaygaming.saneqt.de
DocumentRoot /var/www/001
</VirtualHost>
FritzboxSettings: port 80 is open and I used this setting Fritzbox DynDns Settings
Strato: Strato Domains
Im really sry for my english, im not the best in scool i hope u can ignore the fact...
Thanks in advance!!
Your apache settings are OK, the problem is with DNS:
onewaygaming.saneqt.de:
;QUESTION
onewaygaming.saneqt.de. IN A
;ANSWER
onewaygaming.saneqt.de. 149 IN A 81.169.145.156
www.SaneQt.de:
www.SaneQt.de. IN A
;ANSWER
www.SaneQt.de. 149 IN CNAME SaneQt.de.
SaneQt.de. 59 IN A 46.243.84.57
At this moment, http://www.saneqt.de/ is responding with Hallo welt so I guess that it has correct settings. If so, you need to configure the CNAME record for onewaygaming.saneqt.de exactly the same as you did for www.SaneQt.de.

Write DNS instead of IP?

I'm working on a project and I would like to make some things in order to be able to handle easier my distant server.
I have a server on which one I installed an API (dolibarr - ERP/CRM software).
This server uses Ubuntu 14.04 and Apache2.
When I want to connect to my software from the net, I open Firefox for example, I write http://172.30.10.XX and I am going to the application login page.
But I would like to create a DNS and domain name in order to connect it easier.
For example :
http://shopmoriba.datasystems.fr instead to write the IP address.
My question is : How I can do that ?
I know that I need to modify some files : /etc/apache2/sites-available/000-default.conf or /etc/hosts but what I need to write exactly ?
My /etc/hosts file looks like :
127.0.0.1 localhost
//127.0.1.1 dolibarr
172.30.10.69 shopmoriba.datasystems.fr
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My /etc/apache2/sites-available/000-default.conf looks like :
<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 webmaster#localhost
DocumentRoot /var/www/html/
# 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
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Thank you by advance
There should be no need to touch the /etc/hosts on your server.
The important thing to make this work is to make the name known to all clients that want to access your application. To do this you basically have two possibiliies:
Add an entry to all /etc/hosts (on windows this is C:\Windows\System32\drivers\etc/hosts) on all clients that are meant to access your application. Doing it this way is not recommended
Add a DNS-record for shopmoriba.datasystems.fr in some DNS-server that will be accessed by all clients that are meant to access the application. If this is solely for internal use go with some DNS-server on your network, perhaps there already is one. If you want to make the application publicly available there is no way around registering an official domain and publishing the hostname via the associated DNS-server.
While you only run one application on your server this will be sufficient. Once you start adding other application that you want to publish under a different hostname you will have to add more <VirtualHost>-sections and add a ServerName-line like
`ServerName shopmoriba.datasystems.fr`
to the respective VirtualHost-configuration.
I ommited the topic of using https since you did not mention you want to use it and especially on servers hosting multiple vhosts it is enough for a separate topic.
You can add the entry to /etc/hosts in the following format:
172.30.10.XX shopmoriba.datasystems.fr
Bear in mind that this will only work on the local machine where the hosts file has changed.

Website resolves to local address using apache reverse proxy

I have set up a reverse proxy with apache and am pointing to 4 other apache wordpress server vm's on my local network.
When I go to the websites on 3 of them (like www.mywebsite.com externally from my computer at work), they resolve fine and the sites produce the page correctly.
When I try to connect to the 4th site, it redirects me to a 192 address which is what I have in the proxy config but it does not resolve correctly like the other sites. I literally copy and pasted each block in the 000-default.conf so I know they are identical.
The proxy works and is moving the traffic but will try to resolve locally. Here is the block from my 000-default.conf.
<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.mywebsite.com
ServerAdmin myemail#gmail.com
DocumentRoot /var/www/html
ProxyPass / http://192.168.1.23:80/
ProxyPassReverse / http://192.168.1.23:80/
# 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
</VirtualHost>
Im not sure what is different between the sites. Ive done this quite a few times and never had the issue. Could this be an issue with the web server on the 4th site? These are all VM's running ubuntu server with lamp.
It looks like it was an issue with the 4th server and how it was handling the index file with wordpress. It seems that Wordpress had to be provisioned locally first. But, I dont remember doing this with the other sites. All is well now.

WAMP server name not found for virtual host in apache

System: Windows7 64-bit
WAMP server 32-bit version: Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12 PHPMyAdmin : 4.1.14 SqlBuddy : 1.3.3 XDebug : 2.2.5
My issue is that when I navigate to my project "local.blamo1.com" - via WAMP "Localhost" chrome returns: "Oops! Google Chrome could not find local.blamo1.com"
I am able to access my project folder with "localhost/local.blamo1.com" - But as I understand it, this is bad practice as it will throw off server mapping by one directory. I would like to be able to access the project with the designated server alias. I have implemented the following...
httpd-vhosts.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.config"
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/local.blamo1.com"
ServerName local.blamo1.com
ServerAlias local.blamo1.com
<Directory "c:/wamp/www/local.blamo1.com">
AllowOverride All
Require local
</Directory>
</VirtualHost>
hosts file
Location: "C:\Windows\System32\drivers\etc\hosts"
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 local.blamo1.com
#::1 localhost
#::1 local.blamo1.com
httpd.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
I have un-commented these lines
Include conf/extra/httpd-vhosts.conf
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Current Diagnosis
Apache httpd -t return: "Syntax OK"
I think this has something to do with my DNS or ports, or whatev - as I do not have enough experience with this level or how the DNS is not able to resolve the domain:
after I tried to ping the project:
ping local.blamo1.com
"Ping request could not find host local.blamo.com. Please check the name and try again.
Please help me understand why I am getting this issue. I have been working on this for a day and a half. Apologies if there is not adequate information for your to make a diagnosis of the problem. I will provide more information as necessary.
All my best.
I was able to solve this issue - props to this post: http://www.tweaksforgeeks.com/windows7/2011/02/windows-7-hosts-file-ignored
The issue appeared to be a corrupted "hosts" files - all I know for sure was that the solution was to delete the hosts file and create a new one with raw text from the old. The causality is inexplicable.
This solve my problem. After hours of making it work. Turns out I was careless about the host file. Saving as txt and then just removing the extension to replace the original file.

Set up Virtual Host, can no longer access http://localhost [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've set up a virtualhost on WAMP. The address is http://privatesite (which works)
However, now that I have set up this virtual host, the default localhost does not work and I'm not sure how to rectify it.
My hosts file looks like this:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 privatesite
My Apache httpd-vhosts.conf file looks like this:
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/privatesite/trunk/"
ServerName privatesite
ServerAlias privatesite
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
ServerAlias localhost
</VirtualHost>
As you can see, I have tried to "resetup" the localhost, however, it all seems to point to my "privatesite" folder now it seems.
VirtualHost *:80 is like a catch all. You will need to either name your "privatesite" something else or add NameVirtualHost entries for localhost or 127.0.0.1.
http://httpd.apache.org/docs/2.2/vhosts/examples.html