I am building a SAAS product which is hosted on abc.com and i will have few clients with domains client1.com, client2.org, client3.in etc.
Now i want to serve my application to each client on their domains like client1.com/app, client2.com/app, client3/com/app
I dont want to host my code on their server..There will only be 1 base code & 1 DB which will be on my site abc.com. So my entire app should run on their domain
The question is, how do I configure this ? I mean client.com will point to their server but client.com/app will execute my application from my server with base url of their own domain ?
Thanks..
So i acheived this by using mod_proxy in virtual host config file of client's server by adding the following line
ProxyRequests off
ProxyPreserveHost off
ProxyPass /app http://mydomian.com
ProxyPassReverse /app http://mydomian.com
ProxyHTMLURLMap http://mydomian.com http://client.com/app
SetOutputFilter INFLATE;proxy-html;DEFLATE
It should be noted that proxy, proxy_http & proxy_html modules must be enabled which can be done by following commands
sudo a2enmod proxy
sudo a2enmod proxy_http
proxy_html might not generally be available so it can be downloaded using this command
sudo apt-get install libapache2-mod-proxy-html
Link - http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Related
I have a web server which contains the files for both domains
1-exemple.id and 2-exemple.info.
I want to run Wordpress on "1" and NodeJs for "2".
1" points to the directory /home/xxxxx/public_html and 2" points to the directory /home/xxxxx/public_html/xxxxx.info.
The issue here is that I have tried a couple of times to get this working. I used iptables for forwarding traffic from port 3000(NodeJs) to 80. This made it worse as the NodeJs server is now showing on both domains 1" and 2".
Looking forward to hear your suggestions.
Please note: I am using CentOs7
If you want to forward traffic to a different port you need to configure Apache as a proxy in your virtual hosts file:
ProxyPass "/" "http://127.0.0.1:3000"
ProxyPassReverse "/" "http://127.0.0.1:3000"
Make sure you activate the proxy modules for Apache:
sudo a2enmod proxy
sudo a2enmod proxy_http
I have an amazon AWS LightSail instance and have installed Node js downloaded from nodejs.org. Now the setup is complete and I am able to launch my nodejs webpage inside LightSail instance using "http://localhost but when I try to do it using the lightsail public IP from any other laptop, it not getting accessible (getting web error as "This site can’t be reached").
I have set the node js to listen to port 80 which is open by default.
A lot of materials shows that bitnami as a way to do it but can't I use normal node js installation to make the website public. Appreciate any guidance on this
Bitnami Engineer here,
You can configure your Nodejs app to use the port 3000 and then configure Apache to ProxyPass the requests to that port. This way you will be able to access your app using http and https. Does that sound good? You will need to run these commands:
Create the folders
sudo mkdir -p /opt/bitnami/apps/myapp
sudo mkdir /opt/bitnami/apps/myapp/conf
sudo mkdir /opt/bitnami/apps/myapp/htdocs
Create a /opt/bitnami/apps/myapp/conf/httpd-prefix.conf file with this content
Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
Add this content to the /opt/bitnami/apps/myapp/conf/httpd-app.conf file
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
Add this line to the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf file
Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf"
Restart Apache
sudo /opt/bitnami/ctlscript.sh restart apache
You have more information in our documentation
https://docs.bitnami.com/aws/infrastructure/nodejs/administration/create-custom-application-nodejs/
I have to tomcat servers running in my server. And I wanted to do a virtual host routing. So initially I tried it with one tomcat which is running in 8081 port and ajp port enabled to 8011 in the tomcat server.xml file
My conf file in the /etc/apache2/sites-available/mydomain_name.com.conf looks likes this
<VirtualHost *:80>
ProxyRequests off
ProxyPreserveHost On
ServerName mydomain_name.com
ServerAdmin ubuntu#mydomain_name.com
ProxyPass / ajp://localhost:8011/
ProxyPassReverse / ajp://localhost:8011/
</VirtualHost>
Then I did
sudo a2ensite mydomain_name.com.conf
sudo service apache reload
Every thing went find, no issues. And I also ensured the port 8011 is listening.
But when I try to access the server from my personal laptop, the request is blocked by Google chrome.
I have enabled these configurations in the server too.
sudo a2enmod proxy
sudo a2enmod proxy_ajp
sudo a2enmod proxy_http
sudo service apache2 restar
Have anyone has came across this issue ? Shedding some light would be really helpful. Because I have done some thing similar 1 year back, then this issue did not occur, and I'm only trying to direct it to the tomcat home page. Which is a bare minimal page.
After several frustrating hours found the issue. Hope this might help if any one came across this same issue.
Although the port 80 was opened via the aws management console security groups, internally the ports were firewall protected by the ip tables. So by removing the ip-tables entry for the port 80 I was able to make the virtual host work.
I've recently installed a nodejs app (keystone) app in my home/myusername/myappname directory.
When I visit www.mydomain.com, nothing displays - even after turning on my nodejs app.
Where should these files be?
I am running ubuntu 16.04.
In the past I have worked with a var/www folder, but I am not using apache - do I need to manually create this folder?
Thanks!
For your app to be visible it has to be running (obviously) and accessible on port 80 (if you want it to be available without adding a port number to the URL).
It doesn't matter where it is on the disk as long as it's running.
You don't need Apache or nginx or any other server. Your Node app may listen on port 80. But alternatively it can listen on some other port and your other server (Apache, nginx, etc.) can proxy the requests to that port.
But if your app is listening on, e.g. port 3000 then you should be able to access it as http://www.example.com:3000/.
Also, make sure that your domain is configured correctly. It's A record for IPv4 (or AAAA for IPv6) of the www subdomain should be equal to the publicly accessible IP address of your server.
And make sure that the port you use is not blocked by the firewall.
Update
To see how you can set the port with Keystone, see:
http://keystonejs.com/docs/configuration/#options-server
It can be either changed in the config or you can run your app with:
PORT=80 node yourApp.js
instead of:
node yourApp.js
but keep in mind that to use the port number below 1024 you will usually need the program to run as root (or add a special privilege which is more complicated).
It will also mean that this will be the only application that you can run on this server, even if you have more domain names.
If you don't want to run as root or you want to host more application, it is easiest to install nginx and proxy the requests. Such a configuration is called a "reverse proxy" - it's good to search for info and tutorials using that phrase.
The simplest nginx config would be something like this:
server {
listen 80;
server_name www.example.com;
location / {
proxy_pass http://localhost:3000;
}
}
You can set it in:
/etc/nginx/sites-available/default
or in a different file as e.g.:
/etc/nginx/sites-available/example
and then symlinked as /etc/nginx/sites-enabled/example
You need to restart nginx after changing the config.
You can find more options on configuring reverse proxies here:
https://www.nginx.com/resources/admin-guide/reverse-proxy/
You need to make a proxy between Apache and your Node.js application because Node.js has a built-in server. Supose your Node.js app is served on 9000 port. Then you need to make a proxy to redirect all trafic in 80 port to 9000 port where the Node.js app is running.
1. Enable mod_proxy
You can do this through a2enmond.
sudo a2enmod proxy
sudo a2enmod proxy_http
2. Set the proxy
Edit the /etc/apache2/sites-available/example.com.conf file and add the following lines:
ProxyRequests Off
Order deny, allow from All
ProxyPass / http://0.0.0.0:9000 ProxyPassReverse / http://0.0.0.0:9000
This basically say: "Redirect all traffic from root / to http://0.0.0.0:9000. The host 0.0.0.0:9000 is where your app is running.
Finally restart apache to enable changes.
I have configured in apache conf/httpd.conf
It like this
And in my vhost.d Directory,I have configured some host like this
and then in my windows computer ,I have configure the driver host to bind the two Domains(test.hr.oa.com,demo.oa.com) to my server ip,but it's no working ,
When I visit the url ,it's always go to the /var/www/html ?
I have restart my apache ,it's no working ,and in httpd.conf file,there is no configure about "/var/www/html" ,but the all domains go to /var/www/html
Finally: I found two httpd.conf config files in my server. It like this
Previously,the apache have in my server,so I have tried
apachectrl restart
and
service httpd restart
they are both no working ,the Server tiped me that I should install httpd,
So I
yum install httpd
then the second httpd.conf file was added to my server.and Configuring the second config file is working.
So I want to know what's the relationship about apache and httpd?