WAMP Virtual Host Allow External Device - wamp

I am trying to use Ionic’s Devapp to test some functionality on my phone. I think that WAMP is not allowing the requests to make it through my virtual server. I am using WAMP 3.1.3 with Apache 2.4 and I think I have it configured correctly, but requests are still not being received. I am using windows 10 and have tried to take down my firewall and allow access through my firewall, but I still have not achieved the results and looking for I was wondering if anyone had any suggestions for me to listen to the specific port provided by the ionic server and that’s used by Devapp with wamp. Does it make a difference that it's a phone? Thanks for your help.
hostd.conf
Listen 0.0.0.0:80
Listen [::0]:80
Listen 0.0.0.0:8001
Listen [::0]:8001
Httpd-vhosts.conf
<VirtualHost 127.1.2.3:80>
ServerName sam
DocumentRoot "c:/wamp64/www/x/public "
<Directory "c:/wamp64/www/x/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8001>
ServerName example.dev
DocumentRoot "c:/wamp64/www/x/public"
<Directory "c:/wamp64/www/x/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require ip 192.168
</Directory>
</VirtualHost>

The format of a Require ip does not use the x, x.y part
Just use
Require ip 192.168
and that means any ip starting with 192.168
So if your router is using 192.168.1.* then use
Require ip 192.168.1
to mean any ip on that subnet from 192.168.1.1 to 192.168.1.255
This answer may also help with connecting from your phone

Related

Google Cloud Platform LAMP setup Laravel 5.4

Looking for help on server problem. I have followed the following steps to set up LAMP on the VM
https://cloud.google.com/community/tutorials/setting-up-lamp
I put my Laravel 5.4 website onto the VM, configure the .env for the following:
APP_URL=website_external_IP
But when I access the website by inserting the website_external_IP on my browser, it returns the following image.
Sorry for being noob of server problems but please let me know what else information should I provide for you to figure out the cause of it. Thank you!
1 EDIT:
In response to John Hanley's suggested site. I further made the following edits on the apache conf:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/laravel_project.conf
sudo vim /etc/apache2/sites-available/laravel_project.conf
and there vim the laravel_project.conf as followings
NameVirtualHost *:8080
Listen 8080
<VirtualHost *:8080>
ServerAdmin admin#example.com
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot /home/user/projects/laravel_project/public
<Directory /home/user/projects/laravel_project/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then
sudo vim /etc/hosts
and add the following line:
127.0.0.1 laravel.dev
then disabled the original conf settings and enable for my site:
sudo a2dissite 000-default.conf
sudo a2ensite laravel_project.conf
Without having the full understanding of the new edits procedures, accessing the page with IP returns the following error:
You don't have permission to access / on this server.
Your Apache web server has directory browsing enabled. Also you do not have a default page present (or enabled) therefore you server is serving up the directory listing.
/etc/apache2/apache2.conf
Remove the word Indexes from this part of your configuration:
<Directory /var/www/>
Options Indexes FollowSymLinks
...
</Directory>

Adding a Django site breaks my virtual hosts on CentOS 7

I have a CentOS 7 server with about 20 domains all managed automatically with a vhosts file in /etc/httpd/conf.d.
I am trying to learn Django and wanted to set up a single domain using it, so I added a specific virtualhost to the .conf file.
The result is that the Django domain works fine but all the other sites are broken (try to use Django but cause errors).
The Django domain has two folders: djangodomain.com for static files and djangodomain.app for the Python files.
How can I integrate a single Django domain into my existing many-domain virtual host setup?
Existing vhosts.conf:
<VirtualHost *:80>
serveradmin username#domain.com
serveradmin username#domain.com
usecanonicalname off
# www.site.com » site.com
rewriteengine on
rewritecond %{HTTP_HOST} ^www\.(.*)$ [nc]
rewriterule ^(.*)$ http://%1 [r=301,l]
# file locations
virtualdocumentroot "/home/username/%0"
<directory "/home/username/*">
allowoverride all
require all granted
options indexes followsymlinks
options +execcgi
options +includes
</directory>
</VirtualHost>
What I added that broke all but the Django site:
<VirtualHost djangodomain.com:80>
ServerName djangodomain.com
ServerAlias www.djangodomain.com
ServerAdmin user#domain.com
DocumentRoot /home/username/djangodomain.com
WSGIScriptAlias / /home/username/djangodomain.app/django.wsgi
<Directory /home/username/djangodomain.app>
Order allow,deny
Allow from all
</Directory>
Alias /robots.txt /home/username/djangodomain.com/robots.txt
Alias /favicon.ico /home/username/djangodomain.com/favicon.ico
Alias /images /home/username/djangodomain.com/images
Alias /static /home/username/djangodomain.com/static
ErrorLog /home/username/djangodomain.logs/error.log
CustomLog /home/username/djangodomain.logs/access.log combined
</VirtualHost>
Crossposted to unix.stackexchange.com
When Apache gets an HTTP request, it needs to know what virtual host is supposed to process this request. Now, the way it works is. Apache picks up the IP address that the client request came into (the server IP, not the client) and it goes through the list of virtual host definitions to find any virtual hosts defined for that IP. If there is more than one, it will look at the Host header and try to match it to a particular ServerName or ServerAlias directive. If it still cannot find one, it will look for a default virtual host.
You have two virtual host definitions. One if the default vhost on port 80 <VirtualHost *:80>. It is the default because it has * for IP. The other is specific for the IP address <VirtualHost djangodomain.com:80>. The IP it uses is whatever djangodomain.com resolves to.
So any request that comes to that IP will be handled by the IP specific config before it might be allowed to drop into default.
To fix this, you need to replace your django virtual host directive with <VirtualHost *:80>, same as your other vhosts. This should put them all at the same parsing priority and it will just use the Host header to figure out the rest.
The said, if you are running a web server with 20+ vhosts, you really need to have better understanding on how it works. Read up on HTTP and web hosting when you have the time.

HTTP to HTTPS redirect Vagrant

So I've been having an issue with Vagrant and Port Forwarding...
Currently, Vagrant is already forwarding ports 80 -> 8080 and 443 -> 8443. Issue is, I don't want a client to have to type ports 8443 and 8080 to access my web page. So now, the client has to type in 127.0.0.1:8080 or 127.0.0.1:8443 to access the webpages.
How would I go about changing this? My current stack is VM, Vagrant, Apache, Django.
I have 2 VHosts setup. Heres my sites-available/mysite.com file
<VirtualHost *:80>
ServerAdmin webmaster#example.com
#ServerName spritebots.com
#ServerAlias www.spritebots.com
ServerName 127.0.0.1
ServerAlias 127.0.0.1
ProxyRequests off
ProxyPreserveHost On
ProxyPass / https://127.0.0.1:8443
ProxyPassReverse / https://127.0.0.1:8443
#Redirect permanent / https://127.0.0.1:8443
</VirtualHost>
<VirtualHost *:443>
WSGIDaemonProcess spritebots
WSGIProcessGroup spritebots
WSGIScriptAlias / /var/www/spritebots/apps/wsgi.py
ServerAdmin webmaster#example.com
#ServerName spritebots.com
#ServerAlias www.spritebots.com
ServerName 127.0.0.1
ServerAlias 127.0.0.1
DocumentRoot /var/www/spritebots/
Alias /media/ /var/www/spritebots/static/media/
Alias /static/ /var/www/spritebots/static/
<Directory /var/www/spritebots/static>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/spritebots/static/media>
Order deny,allow
Allow from all
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/spritebots.crt
SSLCertificateKeyFile /etc/ssl/certs/spritebots.key
</VirtualHost>
So I bought a domain name, spritebots.com and I can't even get spritebots.com to point to 127.0.0.1:8443.
But for now, I would like for anyone visiting my site at 127.0.0.1, to be redirected 127.0.0.1:8443, then mask the port number. Basically like how every production web page is with HTTPS enabled.
Does a majority of developers/companies use vagrant or VMs for production web sites? Because I feel that Vagrant's port forwarding is messing this up. Or it's more possibly me just being ignorant of web development. :(
Any help would be greatly appreciated!
In your Vagrantfile, you can assign your VM a private network IP, by dropping in:
config.vm.network "private_network", ip: "192.168.50.5"
Then you don't have to mess with ports.

how to serve website with apache over the internet?

I have somehow managed to serve both my project app and its static files on the apache. But only I can see my webpage, by typing localhost and by my IPv4 address. And I can't see my webpage from the other's computer. In my http.conf, it is Listen 80. I don't know much about this. I even registered on a free dynamic DNS provider, but even from that url I can only see It works message. I really suck at these things. Please guide me here. Thank you.
snippet of http.conf:
WSGIScriptAlias / C:/Users/robin/web/etc/etc/etc/wsgi.py
WSGIPythonPath C:/Users/robin/web/etc/etc
<Directory C:/Users/robin/web/etc/etc>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
#Alias /robots.txt /path/to/mysite.com/static/robots.txt
#Alias /favicon.ico /path/to/mysite.com/static/favicon.ico
AliasMatch ^/([^/]*\.css) C:/Users/robin/web/etc/etc/static/styles/$1
#Alias /media/ /path/to/mysite.com/media/
Alias /static/ C:/Users/robin/web/etc/etc/static/
<Directory C:/Users/robin/web/etc/etc/static>
Order deny,allow
Allow from all
</Directory>
#<Directory /path/to/mysite.com/media>
#Order deny,allow
#Allow from all
#</Directory>
WSGIScriptAlias / C:/Users/robin/web/etc/etc/etc/wsgi.py
<Directory C:/Users/robin/web/etc/etc/etc>
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
You need to do the following:
1. Ensure that the server is publicly accessible
To do this you need to ensure
Port 80 is routed through your router to the servers internal IP address. This is called NAT. If you are using a Cisco router you can see the instructions here.
Any firewalls are configured not to block the traffic on port 80. If you are using Linux you would most likely need to configure iptables. If you are using Windows you can do this on the windows firewall. If you are using a third party firewall you need to search google to find out how to do it.
You need to ensure you are using the public ip address to connect. You can find this by using a website such as http://whatismyipaddress.com/
2. Setup the virtual hosts on apache
The reason you are only seeing the "It Works" message is because Apache is pointing to the default web root on the server for that domain name. To fix this, you need to setup a virtualhost for the domain name, and point it to the root directory of your application. Instruction for this can be found here.
Under for virtual hosts in your apache config, you could add something like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email]#[address].com
DocumentRoot [directory root]
ServerName [registered domain name without www eg: something.com]
ServerAlias *.[registered domain name without www]
</VirtualHost>
The "NameVirtualHost *:80" might already exist, so search the config first. Usually it is in there and commented out by default, so you might just need to remove the #.
Note: ALWAYS backup the config by copying the contents to another file. Also restart apache after you make the adjustment.

Wamp Virtual Host Set Up

sorry for having a similar question to what has been posted all ready but the others aren't helping me.
I'm trying to set up a virtual host on my windows 8 computer but I can't seem to get it to work no matter what tutorial or help section i follow, this is my setup so far.
httpd-vhosts.conf
# Virtual Hosts
#
# Required modules: mod_log_config
Listen 80
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Program Files (x86)\2. Apps\Wamp\www"
ServerName localhost
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Users\Chris\Documents\Projects\testsite\Site"
ServerName testingsite
ServerAlias testingsite
<directory "C:\Users\Chris\Documents\Projects\testsite\Site">
Options Indexes FollowSymLinks
Order Allow,Deny
Allow from all
</directory>
</VirtualHost>
hosts
# Wamp Server Settings
127.0.0.1 localhost
127.0.0.1 testingsite
httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
If i try to start wamp the icon goes orange.
If i run httpd.exe from command prompt i get the following error:
C:\Program Files (x86)\2. Apps\Wamp\bin\apache\apache2.4.2\bin>httpd.exe
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted. : AH00072: make_sock: could not bind to address [::]:80
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted. : AH00072: make_sock: could not bind to address 0.0.0.0:
80
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs
I read that another program might be blocking it or my firewall but i don't know how to fix it, any ideas?
Thanks
Thanks for everyone's input, there were two main problems
I installed wamp into a folder which was nested in a folder who's name had a space in so c:/folder/folder with a space/wamp/ which i have since been told is bad practice, if anyone knows why please tell.
The were issues with the internet protocol, namely ipv6, so solve this you need to ensure wamp only uses ipv4, inside httpd.conf find Listen 80 and change to Listen 0.0.0.0:80. Again i'm not sure what this does so if anyone knows please post below.
I hope this helps anyone else stuck.