When one registers a url with a dns registrar can they include port mapping to the host computer?
www.myurl1.com myip:80
www.myurl2.com myip:81
Basically can one map several urls to the same host computer using port 80 as seen from the outside(so one doesn't have to do www.myurl2.com:81)?
You can add Virtual Hosts to your webs-servers conf file. Just have your dns registrar point all your domains to the same IP# port :80 and the web-server will do the rest.
See http://httpd.apache.org/docs/2.0/vhosts/
Apache httpd.conf example:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/myurl1.com/"
ServerName myurl1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/myurl1.com/"
ServerName myurl2.com
</VirtualHost>
Nginx - See http://wiki.nginx.org/ServerBlockExample
Related
I need to create a reverse proxy in apache2 for an icecast server, but with another virtualhost as a simple website
I managed to create the reverse proxy, using this configuration in apache Virtualhost
<VirtualHost 100.100.100.100:80>
ServerName icecast.xxx.com
ProxyPass / http://localhost:8000/
</VirtualHost>
100.100.100.100 is the ip of the server, and xxx.com is the domain
So when i type in my browser icecast.xxx.com the icecast admin panel (on 8000 port) show up
Then i have added another virtualhost
<VirtualHost *:80>
ServerName xxx.com
ServerAlias www.xxx.com
ServerAdmin MY_EMAIL
DocumentRoot /var/www/site/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have enabled him with sudo a2ensite NAME_OF_THE_CONFIG_FILE
But when I go to the ip of the VPS or to xxx.com/www.xxx.com the icecast2 admin panel show up!
I don't know how to solve this, I maybe think that the error is in the line
I finally managed to solve the issue,
simply in the reverse proxy virtualhost, instead of <VirtualHost 100.100.100.100:80>
I need to put
<VirtualHost *:80>
My Needs are
1. Configure Multiple Domain on XAMPP server on production (Woocommerce Site)
2. Configure and enable ssl
Steps i followed
Edited httpd-vshost as
NameVirtualHost *:80
ServerAdmin mail#firstsite.in
DocumentRoot "C:/xampp/htdocs/firstsite"
Allow from all
ServerName firstsite.in
ServerAlias www.firstsite.in
ServerAdmin mail#secondsite.in
DocumentRoot "C:/xampp/htdocs/secondsite"
ServerName secindsite.in
ServerAlias www.secondsite.in
Allow from all
Edited httpd-ssl
<VirtualHost _default_:443>
ServerAdmin admin#localhost
DocumentRoot "C:/xampp/htdocs/firstsite"
ServerName firstsite.in:443
ServerAlias www.firstsite.in:443
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
SSLEngine on
SSLCACertificateFile "C:\xampp\apache\conf\mibstore\ca_bundle.crt"
SSLCertificateFile "C:\xampp\apache\conf\mibstore\server.crt"
SSLCertificateKeyFile "C:\xampp\apache\conf\mibstore\server.key"
</VirtualHost>
<VirtualHost _default_:443>
ServerAdmin admin#localhost
DocumentRoot "C:/xampp/htdocs/secondsite"
ServerName secondsite.in:443
ServerAlias www.secondsite.in:443
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
SSLEngine on
SSLCACertificateFile "C:\xampp\apache\conf\ricebazzar\ca_bundle.crt"
SSLCertificateFile "C:\xampp\apache\conf\ricebazzar\server.crt"
SSLCertificateKeyFile "C:\xampp\apache\conf\ricebazzar\server.key"
</VirtualHost>
I have obtained SSL certificate from sslforfree and stored them on relevant path
I also edited etc\hosts file
127.0.0.1 firstsite.in
127.0.0.1 secondsite.in
Issue
I can able to browse them from the server(windows) itself , but can't able to access them from outside. the relevant domain names are purchased and added a A record to point the IP.
Notes
Using Amazon AWS EC2 instance
Added Inbound Rules on 80 & 443, And also added firewall rules on 80 & 443
Would you tried in another PC to visit them since you changed your host file on your PC.
If they can be visited then you need remove the record of your host file.
If not, please try:
Does both the A record of WWW and Non-WWW have been pointed to IP.
If pointed, please tell me what error or message you see on browser when you load the websites.
If there're no error or message which means they are blank page, please try to check is there any htaccess file, do you enable the rewrite mod of xampp.
I installed Drupal 8 with MAMP. My MAMP preference number for Apache Port : 80 , Nginx Port: 80 and MySQL Port: 8889
In etc/hosts file, I add 127.0.0.1 mmcast.test
In httpd.conf file,
Listen 80
and uncomment the following line.
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
In httpd-vhosts.conf file,
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName mmcast.test
DocumentRoot "/Applications/MAMP/htdocs/mmcast"
</VirtualHost>
When I call the site, I type mmcast.test:8888 and also try with mmcast.test:80. However, nothing works! :(
Could someone help me please? I've been trying this problem and still cannot solve.
in httpd.conf file
ServerName localhost:8888
has to be changed to
ServerName localhost:80
For Drupal 8 you need different settings for creating virtual host.
Here is the snippet that needs to be added for virtual host:
<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs/site-name/web"
ServerName local.site-name.com
<Directory /Applications/MAMP/htdocs/site-name/web/>
Options Indexes FollowSymLinks
AllowOverride all
RewriteEngine On
RewriteBase /
</Directory>
</VirtualHost>
So I access my local site as
local.site-name.com:8888
I have used default port, which is 8888. So above snippet is according to it.
You can refer this link from Drupal.org as well.
Can i run different websites in same domain. like
http://www.example.com ----> in WordPress
https://example.com/ -----> in laravel
Here is the reference site
Website : www.linqs.in
APP: https://linqs.in/username
App url will open user's profile by provided username.
sorry if i made mistake !! if this possible please guide me.
You can do this in your virtual host configuration:
Listen 80
Listen 443
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/path/to/wordpress"
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
DocumentRoot "/path/to/laravel/public"
</VirtualHost>
You may also need to define directories if the sources are not under your default http root. For example:
<VirtualHost *:443>
ServerName example.com
DocumentRoot "/path/to/laravel"
<Directory /path/to/laravel>
AllowOverride All
</Directory>
</VirtualHost>
This will also allow Apache to serve that directory and use any .htaccess files (if it wasn't allowed already).
Since URL listen on port like http - port 80, https - port 443. So, you can ensure different website in a same domain via VirtualHost configure.
I'm developing locally using wamp and i've configured the enviroment to handle more than one site, but i want to access a specific site using an ip address, i don't know if i have to add a port after the 127.0.0.1.
The following are my host settings.
127.0.0.1 localhost
127.0.0.1 www.site1.net
127.0.0.1 www.site3.com
and on vhosts.
<VirtualHost *:80>
ServerAdmin www.site1.net
DocumentRoot "c:/wamp/site1/"
ServerName www.site1.net
ServerAlias www.site1.net
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin www.site2.com
DocumentRoot "c:/wamp/site2/"
ServerName www.site2.com
ServerAlias www.site2.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
Problem
When i put 127.0.0.1 in my address bar it goes to site1, and i don't know how to access site2 using ip.
Why i want this.
Because when i try to access this sites from another device on the same network they don't work unless i use this ip: 172.20.10.4, this on the iphone, and this ip goes to localhost which is site1 and then i can't access site2.
But just www.site.net or www.site2.com works on the machine running wamp.
Edit. This is what is tried.
I put some ports on the 'listen' part of the httpd.confi;
Listen *:80
Listen *:8182
Listen *:8383
And changed htttpd-vhosts;
<VirtualHost *:80>
ServerAdmin localhost
DocumentRoot "c:/wamp/"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:8181>
ServerAdmin www.site1.net
DocumentRoot "c:/wamp/site1/"
ServerName www.site1.net
ServerAlias www.site1.net
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:8182>
ServerAdmin www.site2.com
DocumentRoot "c:/wamp/site2/"
ServerName www.site2.com
ServerAlias www.site2.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
This works on the devices, like on the iphone i can dial 172.20.10.4:8181 and it goes to site1 and 8182 goes to site two.
NEW PROBLEM
The url of the sites are now messed up, i can only access this sites by their ip with ports but not their domain names, so on the local machine 127.0.0.1:8181 goes to site 1 but www.site1.net doesn't find the server directory where this site is located.
OK
If you use an ip address (from another PC on your network ) and not a url like www.site2.com Apache will not know what site it should run so it always picks the first site it find in the VHost definition file and takes the connection there.
So if you want to access your sites from other PC's on your internal network you either have to run your own DNS Server ( bit complicated ) or on each of the other PC's you need to setup their HOSTS file to know about your 2 sites i.e.
HOSTS FILE ON YOUR OTHER PC's assuming your WAMPSevrer is running on 192.168.1.10
192.168.1.10 www.site1.net
192.168.1.10 www.site2.com
Now these other PC's can use the correct url i.e. www.site1.net or www.site2.com and the Apache server will know which site to send the connection to.
Now I think you mentioned a Phone. This is a little more complex as you cannot get to the HOSTS file on a phone ( possibly you can if you have jailbroken it )
So for this I used a bit of a work around.
I use Fiddler, its a tool for viewing whats going up and down the line between a browser and the server from the PC running the browser.
But you can also use it as a Proxy I think this is the documentation
Basically you set it up to listen for connections on lets say port 8888 and then you add a line to its existing script to tell it to go to a specific url when it sees connections on 8888, you can therefore use a url in the phone like 192.168.1.10:8888 to get to site1.net then change the script so it goes to site2.com
Its a bit conveluted but it worked for me.
Answer to second problem
You dont mention what version of WampServer or Apache you are using so I added a test for the version in the new lines.
You have made a few mistakes in the definition of your virtual hosts. See below for corrections
<VirtualHost *:80>
ServerAdmin me#mysite.net
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
<Directory "D:/wamp/www">
AllowOverride All
<IfDefine APACHE24>
Require local
Require ip 192.168.2 <- change to your subnet first 3 quartiles
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.2 <- ditto
</IfDefine>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#site1.net
DocumentRoot "c:/wamp/www/site1"
ServerName www.site1.net
ServerAlias site1.net
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
<Directory "D:/wamp/www/site1">
AllowOverride All
<IfDefine APACHE24>
Require local
Require ip 192.168.2 <- change to your subnet first 3 quartiles
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.2 <- ditto
</IfDefine>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#site2.com
DocumentRoot "c:/wamp/www/site2"
ServerName www.site2.com
ServerAlias site2.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
<Directory "D:/wamp/www/site2">
AllowOverride All
<IfDefine APACHE24>
Require local
Require ip 192.168.2 <- change to your subnet first 3 quartiles
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.2 <- ditto
</IfDefine>
</Directory>
</VirtualHost>
Basically you need to tell each apache which IP's can access each vhosts folder.
So you could keep your modified ports if you wish but keep the <Directory>...</Directory section.
Also check yor HOST file, it was probably a typo when you wrote your question but you have said your hosts file looks like this
127.0.0.1 localhost
127.0.0.1 www.site1.net
127.0.0.1 www.site3.com
It should be this:
127.0.0.1 localhost
127.0.0.1 www.site1.net
127.0.0.1 www.site2.com
it will complicate, please do not use the same server's ip address not or the same server name.. each computer has unique ip, so provide the right ip and do not dupilcate the sitename of your project.. if you have 192.168.1.1 for site1.come then you should use 192.168.1.100 for site2.com.. 127.0.0.1 represents only 1 server ip and 1 sitename only.. please be guided with these difference because calling two persons in one address might result in one and your expecting to have 2 simultiniously.. thanks!