I have two different web applications running on port 3000 (grafana) and port 3001 (metabase) as you can see below:
tcp 0 0 127.0.0.1:3001 0.0.0.0:* LISTEN -
tcp6 0 0 :::3000 :::* LISTEN -
I have set up apache virtualhost in /etc/httpd/conf.d/default-site.conf as follows
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /metabase/ http://127.0.0.1:3001/
ProxyPassReverse /metabase/ http://127.0.0.1:3001/
</VirtualHost>
However when I try to access this using domainname.com/metabase/ it does not route there but instead routes to grafana running on port 3000.
How can I configure Apache to route my requests to metabase?
Related
I have a domain (e.g. example.com) registered with godaddy.com and use AWS for hosting.
Nameserver on Godaddy later added to AWS
I have an ubuntu (t2.medium) apache server installed. My project in Docker has LAMP, ELK, Node, React, and Postgres installed. Everything works on the local system using direct ports. Few ports open in my project i.e.
example.com:3000 react app [frontend]
example.com:5601 kibana app
example.com:5050 postgradmin app
example.com/radius php applicatinn [backend]
example.com:8080 phpmyadmin app
my desired URLs are:
example.com:3000 react app [frontend] => http://example.com
example.com:5601 kibana app => http://kibana.example.com
example.com:5050 postgradmin app => http://postgradmin.example.com
example.com/radius php applicatinn [backend] => http://example.com/radius
example.com:8080 phpmyadmin app => http://phpmyadmin.example.com
I have tried a few things but nothing is working. on route53
tried reverse proxy on apache by adding separate conf files e.g.
default.conf
<VirtualHost *:80>
ServerAdmin contact#example.com
DocumentRoot "/var/www/html"
ServerName example.com
<Directory "/var/www/html/">
AllowOverride all
</Directory>
</VirtualHost>
kibana.conf
Listen 5601
<VirtualHost *:5601>
ServerAdmin contact#example.com
ServerName kibana.example.com
</VirtualHost>
pgadmin.conf
Listen 5050
<VirtualHost *:5050>
ServerAdmin contact#example.com
ServerName pgadmin.example.com
</VirtualHost>
when I run docker-compose up on EC2, http://example.com/radius works fine. but others do not (e.g. http://kibana.example.com). but if try with port directly (e.g. example.com:5601) it's working. but I want to use a sub-domain not a domain with a port.
How to do that?
reverse proxy I tried as mentioned in the description but it's not working properly
First, if you want your domains to be publicly accessible. You need to create records for all domains.
Second, if you want to access by only domains without port, you should create multiple blocks of virtual host listening to only port 80, and then do the routing base on domains your server received
Example can be found here
I recently launched an ecs instance with centos 7.3.
I followed a guideline to install apache and configure ports(80 and 443).
I try to visit http://my_ip but it's not responding, it says i should check proxy and firewall
Below is the iptables, i could not figure what's wrong
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25141/httpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1878/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 25141/httpd
tcp6 0 0 :::3306 :::* LISTEN 30048/mysqld
1.stop firewall(systemctl stop firewalld.service),make your selinux equal disabled(vim /etc/sysconfig/selinux)
2.check your apache configure file and make sure your configuration allow your client to access.
3. check your apache access.log and error.log
you can try these method,and you would better paste the error page screenshot.
I have purchased .crt certificate file from ssls.com for enabling SSL and I tried some method to configuring it in AWS ec2.
Like i added this code in httpd.conf
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
# !important below!
NameVirtualHost *:443
Listen 443
<VirtualHost *:443>
ServerName mydomain.com/
#other configurations
SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt/mydomain.com.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/localhost.key
After that if i run this code its giving error.
please help me. do i need to do any other thing.
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.
I'm developing my first Django application, I have installed allauth to permit openid login.
I'm trying to use no-ip dns to avoid the problem of the dynamic ip, for register my app on facebook and testing from my machine. But I don't know how to make my django test server visible from outside on port 80.
If I force it using sudo it gave me problems on logging to postgrel database, but if I not use sudo it says that I can't use that port (also if apache is off).
Thank you for your help.
One way is to create virtual host in apache, which will use mod_wsgi to talk to a Django app.
Example:
<VirtualHost *:80>
ServerName xxx.xxx.com
ServerAdmin webmaster#localhost
WSGIScriptAlias / /var/www/xxx/apache/xxx.wsgi
Alias /static/ /var/www/xxx/static/
DocumentRoot /var/www/xxx
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/xxx-error.log
CustomLog ${APACHE_LOG_DIR}/xxx-access.log combined
</VirtualHost>
Contents of xxx.wsgi:
import os, sys
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append('/var/www/xxx')
os.environ['DJANGO_SETTINGS_MODULE'] = 'xxx.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
"Redirecting" port 80 to port 8000
You won't be able to bind to port 80 without using sudo, it's a protected port that only root can bind to. (Like any port below 1024)
Here's a simple iptables rules that will forward requests to port 8000 onto port 80, so you can "pretend" to access your server at port 80 while serving it at port 8000.
It only works for the loopback interface (e.g., you on your own computer talking to itself), but that should be what you need for development.
iptables -t nat -I OUTPUT --source 127.0.0.1 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8000
Should you need it, for an exterior client, the rule is:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8000 (edit the interface if needed)
Alternate solution
You can however have a look at this question: Is there a way for non-root processes to bind to "privileged" ports on Linux?, which indicates another solution to your issue.
Please do pay attention to the point concerning interpreted languages (such as python).
A word of warning
This is obviously only intended for development purposes. To run your app, you should be using nginx + gunicorn or apache + mod_wsgi.
I would use an nginx proxy pass. On Ubuntu, all you have to do is sudo apt-get install nginx, then sudo nano /etc/nginx/sites-available/default. Change the location / block to this:
location / {
proxy_pass http://localhost:8080; #or whatever port you are using
proxy_set_header Host $host;
}
and uncomment the listen 80; line and change it to listen 127.0.0.1:80 (this will prevent your development site from accidentally being served to the entire internet on port 80). You may also have to change the server_name if you want to do anything with /etc/hosts to make your site think it is elsewhere.
sudo service nginx start and you'll be in business. Note that nginx may need to be manually started after boot; I don't think the default is for it to start on boot every time.