Can't Get VirtualHosts to Work on Raspberry Pi or iPad Pro - ipad

I setup a LAMP stack on my RaspberryPi with VirtualHosts so I can code in a local environment from my iPad Pro and its been working but when I tried to incorporate github it became an issue when creating a local repo in /var/www/.
So I found this doc here: https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-ubuntu-18-04 and moved the Web Root to /home/pi/dev/.
the setup is working with 1 site when I visit the IP address of my RPi (192.168.1.5) from safari on my iPad Pro and the browser on the RPi but visiting site1.dev does not work for either.
This is how I have VirtualHosts setup so far.
etc/apache2/sites-available/site1.conf (symlinked to etc/apache2/sites-enabled/site1.conf:
<VirtualHost *:80>
ServerAdmin name#email.com
Server Name site1.dev
ServerAlias www.site1.dev
DocumentRoot /home/pi/dev/site1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /home/pi/dev/site1>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
/etc/hosts:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 raspberrypi
192.168.1.5 site1.dev
192.168.1.5 site2.dev
192.168.1.5 site3.dev
I restarted apache with sudo systemctl reload apache2 but still can't get site1.dev, site2.dev, or site3.dev to load on my RPi or my safari browser on my iPad Pro.. any suggestions?

Related

Configuring SSL with apache server in a docker container

I am setting up a LAMP app in a docker container hosted in ubuntu. I am a docker noob
I generated the CSR on the server that is hosting the docker container that has the public IP and domain i am using.
In my Docker file I have
COPY ./dev.key /etc/apache2/ssl/dev.key
COPY ./dev.combined /etc/apache2/ssl/dev.combined
Then in the apache.conf i have
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/dev.combined
SSLCertificateKeyFile /etc/apache2/ssl/dev.key
ServerAdmin admin#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The problem is when i try to start apache I get the error:
AH02565: Certificate and private key 127.0.0.1:443:0
from /etc/apache2/ssl/dev.combined and /etc/apache2/ssl/dev.key do not
match AH00016: Configuration Failed
There is something i am not understanding in configuring this docker image.
The Domain has a real public IP , so the CSR and Cert need to point to this IP.
Am I setting up something incorrectly in Docker so it thinks it is running 127.0.0.1 and not the IP i need?
Thanks for any help. I am in way over my head.
I found the solution.
I was close. I had to make a couple of changes
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/dev.crt
SSLCertificateKeyFile /etc/apache2/ssl/dev.key
SSLCertificateChainFile /etc/apache2/ssl/dev.ca-bundle
But the thing that fixed the 'Certificate and private' error..
I had to add my domain in my /etc/host on the server that hosted the docker
127.0.0.1 mydomain.dev localhost

rails deployment not working on port 5000

Hi I am trying to deploy a rails application on linux. I have configured everything in my app and then I have configured app.conf file in /etc/apache2/sites-available
<VirtualHost *:80>
ServerName xx.xx.xx.xx /ip of my server
ServerAlias xx.xx.xx.xx / ip of my server
ServerAdmin user#localhost
DocumentRoot /myapp/current/public
RailsEnv testing
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/myapp/current/public">
Allow from All
Options -MultiViews
AllowOverride all
Options FollowSymLinks
Require all granted
</Directory>
And my app is running fine when I go to xx.xx.xx.xx , but I change the port 80 to 5000 and go to xx.xx.xx.xx:5000 , app is not running.
Can anyone help me out on this. what I suppose to do ?

rails deployment in subdomain

on a dedicated server Debian 7, my default domain is www.example.org
I installed a mail server as smtp.example.org on localhost, running fine
I would like to deploy a rails app as a subdomain as : myapp.example.org
I deployed correctly the app, w Capistrano , and added a vhost :
<VirtualHost *:80>
ServerAdmin webmaster#example.org
ServerName myapp.example.org
ServerAlias myapp.example.org
DocumentRoot /var/www/rails/staging/myapp/current/public
<Directory /var/www/rails/staging/myapp/current/public>
AllowOverride All
Options -MultiViews
</Directory>
</VirtualHost>
the I enabled the site and restarted apache and tried to get http://myapp.example.org
but I always get the default site : http://www.example.org
my /etc/host is the following :
127.0.0.1 localhost smtp.example.org
localhost.localdomain localhost smtp
when I perform in the console : apache2ctl -S, I get
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
...
*:80 is a NameVirtualHost
...
port 80 namevhost myapp.example.org (/etc/apache2/sites-enabled/myapp.example.org:1)
what did I missed ?
Found the answer at :
http://shapeshed.com/developing-subdomain-rails-sites-locally/
in the vhost file , I changed :
ServerAlias *.example.com
...
Options +FollowSymlinks +SymLinksIfOwnerMatch
RackEnv staging # or development or production

Mac OSX Lion Apache + RubyOnRails + mod_passenger

I'm trying to learn how to develop web application with Ruby On Rails but I've incurred in a silly error.
I'm trying to use Phusion Passenger aka mod_rails to use Apache instead of WEBrick; I've installed the module via gem and run the
sudo passenger-install-apache2-module
command to install passenger; then I edited the http.conf file adding
LoadModule passenger_module /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19
PassengerRuby /Users/Stopped/.rvm/wrappers/ruby-1.9.3-p327/ruby
added the VirtualHost
<VirtualHost *:80>
ServerName rails.local
DocumentRoot "/Users/Stopped/RoR/prova/public"
<Directory /Users/Stopped/RoR/prova/public>
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restarted Apache with sudo apachectl restart but It's not working :( If I lookup in localhost I see the "It works!" page but if I go at rails.local there is not my Rails app :(
Passenger is loaded
Apache/2.2.22 (Unix) Phusion_Passenger/3.0.19 DAV/2 PHP/5.4.9 Server at localhost Port 80
Any ideas?
PS: This is "apachectl -S" output
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
port 80 namevhost rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
Syntax OK
SOLUTION
Uhm... I solved it, adding 127.0.0.1 rails.local to my hosts file but I can't understand why; can someone explain this to me? ._.
you can't use a wildcard with localhost in your hosts file. you have to explicitly specify each subdomain for localhost in your hosts file. if you're looking for an alternative, you could buy a domain name and point that domain name to 127.0.0.1 with a wildcard. you could even go a step further and have a skeleton app which points different subdomains to different applications by mapping the routes.

EC2onRails + SSL + Apache: No response on port 443

I'm trying to configure SSL on EC2onrails with no luck. At present I am unable to even telnet into my server at port 443, it simply says trying MY.IP.ADDRESS... and stays there indefinitely. Telnet into 80 works fine.
This was my starting point. I followed the instructions exactly, and because I have a go daddy cert I created this custom default-ssl file so I could add the SSLCertificateChainFile directive:
NameVirtualHost *:443
<VirtualHost *:443>
Include /etc/apache2/sites-available/app.custom
Include /etc/apache2/sites-available/app.common
ErrorLog /mnt/log/apache2/error.log
LogLevel warn
CustomLog /mnt/log/apache2/access.log combined
# see http://httpd.apache.org/docs/2.2/ssl/ssl_intro.html and http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
SSLEngine On
SSLCertificateFile /etc/ec2onrails/ssl/cert/ec2onrails-default.crt
SSLCertificateKeyFile /etc/ec2onrails/ssl/private/ec2onrails-default.key
SSLCertificateChainFile /etc/ec2onrails/ssl/cert/ec2onrails-chain.crt
RequestHeader set X_FORWARDED_PROTO 'https'
ServerName MY_SERVER_NAME
</VirtualHost>
Note that I had to add
ServerName MY_SERVER_NAME
Or else I saw the following warning at apache startup in the error.log file:
[Wed May 27 19:46:20 2009] [warn] RSA server certificate CommonName (CN) ` MY_SERVER_NAME' does NOT match server name!?
I have run cap ec2onrails:server:enable_ssl, apache boots up cleanly, regular access over port 80 works, and apache access logs indicate no request activity to port 443. I know apache is loading my default-ssl config files because if I type gobbledygook in them it complains at startup.
Has anyone else successfully gotten SSL working with EC2onRails? What else can I do to debug this issue? Right now I am using ec2onRails version 0.9.9.1 which is based on a version of Ubuntu.
OK I figured it out. Amazon's EC2 has it's own firewall as part of its "security group" concept. This firewall was blocking port 443.

Resources