Reverse Proxy through Apache2 for Odoo 11 - dns

This is the script I've written in my .conf file of sites-available folder.
<VirtualHost *:80>
ServerName erp.abclabs.com
ProxyPass / http://35.134.151.156:8069/
</VirtualHost>
And this is what I've added in my /etc/hosts file.
35.134.151.156 erp.abclabs.com
127.0.0.1 localhost
Yet I'm not able to redirect the service to my domain name. I've also started the 'proxy' and 'proxy_http' service from the sites-enabled location.
What am I doing wrong?

Have you redirected the domain to this IP? I think Nginx is much better than Apache

Related

Apache default root doesn't change for my domain in linux server

I know in Apache, there are virtual hosts. When a request is given, it goes and search between these virtual hosts to see if there are server name like request. It takes its option back like document root and others I have this file in /etc/httpd/sites-enabled:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example.com/html
ErrorLog /var/www/example.com/log/error.log
CustomLog /var/www/example.com/log/requests.log combined
</VirtualHost>
I defined all directories as well like /var/www/example.com/html and after all that, I have a file named /etc/httpd/conf at its last line I added this code:
Include sites-enabled/*.conf
After that when I restart httpd it performs complete with no errors, but it doesn't work and it goes to its default root. Where is the problem?
Once you create a virtual host configuration file, in your example, /etc/apache2/sites-available/example.com.conf
You need to use the command as super user
a2ensite example.com
And then restart Apache:
systemctl reload apache2
You can tell what virtual hosts are up and running by the command:
apache2ctl -S
i solve it just with replacing star with my local ip in linux in virtualhost tag
<VirtualHost ip:80>
after too many examination it works finally.there was no problem in other places.

Run NodeJS app on httpd subdomain

Thanks in advance for your help,
I want to launch a nodeJS application through httpd (RedHat) in a server that has a lot of VirtualHosts, so I went to the httpd conf file located at /etc/httpd/conf/httpd.conf and added in the end of the file the following configuration:
<VirtualHost *:80>
ServerName subdomain.example.com
ProxyPreserveHost on
ProxyPass / http://localhost:8080/
</VirtualHost>
My NodeJS app is running on localhost:8080 but when I go to subdomain.example.com I am just getting a Server Not found error. Tried a lot of combinaisons in the httpd config file that I have found in the internet but in vain. I restart the httpd service everytime I did a change to the config file by running service httpd restart
This was only a DNS propagation issue. Fixed by adding an A record to the DNS entries.

Apache Multi-project configuration

I have a server with an ip: XXX.XXX.XXX.XXX
In my server, i have several projects in the folder /var/www:
/var/www/project1
/var/www/project2/trunk/webroot
...
My 000-default.conf is like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Currently I access into them through the following url:
XXX.XXX.XXX.XXX/project1
XXX.XXX.XXX.XXX/project2/trunk/webroot
...
I have a domain that targets to my server
domain.com -> XXX.XXX.XXX.XXX
My intention is to create a subdomain for each project, and each subdomain points to the target folder of the project:
project1.domain.com -> XXX.XXX.XXX.XXX/project1
project2.domain.com -> XXX.XXX.XXX.XXX/project2/trunk/webroot
(I think the best solution will be that XXX.XXX.XXX.XXX/project2 targets directly to XXX.XXX.XXX.XXX/proyect2/trunk/webroot)
I have read that it will be great that each project has its own .conf file in apache, and enabling each site separately.
But I think that if I create a VirtualHost *:80 for each project (project1.conf, project2.conf) they will be in conflict and I dont know how to do it.
Can anybody help me?
Regards.
Virtual Host is the way to go... create one virtual host for each domain pointing to a folder on your server where to webpage is sotored.
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
</VirtualHost>
Etc... One VirtualHost for each domain / DocumentRoot convination
Soruce: https://httpd.apache.org/docs/current/vhosts/examples.html
##################### EDIT
I have tested it on my own server
Whithout touching the default.conf file I have created two new config files
root#raspberrypi:/etc/apache2/sites-available# pwd
/etc/apache2/sites-available
root#raspberrypi:/etc/apache2/sites-available#
Please ignore the default files I have not touched them I have just created two new files named project1.... and project2....
root#raspberrypi:/etc/apache2/sites-available# ls
000-default.conf project1_domain_com.conf
default-ssl.conf project2_domain_com.conf
root#raspberrypi:/etc/apache2/sites-available#
root#raspberrypi:/etc/apache2/sites-available# cat project*
<VirtualHost *:80>
DocumentRoot "/var/www/projects/project1/"
ServerName project1.domain.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/projects/project2/"
ServerName project2.domain.com
</VirtualHost>
root#raspberrypi:/etc/apache2/sites-available#
ENABLING SITES
root#raspberrypi:/etc/apache2/sites-available# a2ensite project1_domain_com.conf
Enabling site project1_domain_com.
To activate the new configuration, you need to run:
service apache2 reload
root#raspberrypi:/etc/apache2/sites-available# a2ensite project2_domain_com.conf
Enabling site project2_domain_com.
To activate the new configuration, you need to run:
service apache2 reload
root#raspberrypi:/etc/apache2/sites-available#
RELOAD APACHE
root#raspberrypi:/etc/apache2/sites-available# /etc/init.d/apache2 reload
[ ok ] Reloading apache2 configuration (via systemctl): apache2.service.
root#raspberrypi:/etc/apache2/sites-available#
################# SUBDOMAIN EDIT
For example I have a single server with an IP XXX.XXX.XXX.XXX that have multiple domains registered (15 domains now).
I have one virtual host entry for each domain that works this way:
domain1.example.com -> Load the domain1 web index.html page (without /nothing/else )
domain2.example.com -> Load the domain2 web index.html page hosted on another folder expecified on the second virtual host.
And finally ussing a2ensite or a2dissite I enable or disable the website as a web hosting provider do...
If for any reason you need that accessing the host domain3.something.com it redirects to domain3.something.com/something/diferent ... it should be done on your server ussing .htaccess file and its a entirely diferent question :D

Apache virtual hosts - server ip directing to virtual host instead of /var/www/html

I have set up a linux box mainly for testing and I have got to a stage were apache, mysql and php are running. I followed tutorials on how to set up virtual hosts so I can point domains to it but something strange is happening.
This is my httpd-vhosts.conf file that I have included in my httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName thedomain.co.uk
DocumentRoot /var/www/thedomain
</VirtualHost>
When I go to thedomain.co.uk it is pointing to the correct place as you'd expect. But when I go to my servers ip, internal or external it is going to the same directory as the virtual host. Could you guys think of any reason that is? I would expect it to go to /var/www/html by default? Oh and I'm running CentOS 6.3
Thanks in advance for any answers!
You have used wildcard to point everything at DocumentRoot /var/www/thedomain
You need to create second listing :
<VirtualHost myotherdomain.co.uk:80>
ServerName myotherdomain.co.uk
DocumentRoot /var/www/myotherdomain
</VirtualHost>
where your other domain is whatver ip and the document root, points to your choise.
The first vhost listing is also used as the default ... so if you were to use localhost it would resolve to whatever is first in list.

Apache subdomains on ubuntu server from laptop

I'm on my laptop and I want to create subdomains for the server on my network. On my laptop, I modified my hosts file so that I can access my server with the adress myserver
If I access myserver, I get the default apache server html page saying "it works".
On my server, the default document root is /var/www/
I want to create a subdomain for a user such that I would type user.myserver and access files at /home/user/Websites/
Now, I modified httpd.conf on my server to add:
<VirtualHost *>
ServerName *
DocumentRoot "/var/www/"
</VirtualHost>
<VirtualHost *>
ServerName user.localhost
DocumentRoot "/home/user/Websites/"
</VirtualHost>
Also, my hosts file on my server is modified to:
127.0.0.1 user.localhost
if I put user.myserver on my laptop, my browser says it can't find the server.
What am I missing ?
You don't need to modify hosts file on your server, it's only for server resolving, apache will just listen to what Host header it will receive.
You need to modify hosts file on your laptop to have user.myserver point to the IP of your server.

Resources