[SOLVED] Ubuntu server with three different services
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
All 3 vhosts should use port 80.
You can create also an apache port-based vhost listening on 8080 and run wordpress on it. And then use the main apache instance (on port 80) to reverse proxy wordpress on port 8080.
Quote:
my Apache also running on port 8080 because Django use port 80
You should configure django listening on a different port, because you cannot have 2 servers using the same port
Bathory beat me to the punch. I think we agree, but I would just run use VH and not have the extra inbound 8080 port.
You have apache listening on like *:3000, and your apps are the same. Proxies typically forward to different servers, so there is no ip/port conflict. In your case, your are forwarding to the same box.
So if your app is listening on *:3000, you are going to get a binding conflict. You can check the binding with like:
netstat -an | grep 3000 | grep LIST
and see what ips port 3000 is binding.
0.0.0.0 means all interfaces, including loopback/localhost, much like * means in Apache.
So for DJango, I would only bind to the a.b.c.d:80 in Virtualhost. If you use the wildcard, you will conflict with localhost, the ip /port Django is listening on. I can't remember if the bind fails, but it certainly order dependent on what server is running first (the first to bind gets it). I think if your wildcard bind and then more specific bind, that is allowed but the more specific bind will get the traffic, but I would not trust this to work.
For wordpress, you don't have to use 8080 can be just 80. It can come in on port 80 and the servername will match it to the instance.
And again, for nodejs, you don't need the 3000, just 80. Virtualhost matching should forward it.
That is the beauty of Virtualhost. You don't need to have separate ips or ports for each vh, the servername matching the URL directs the traffic to the right vh.
And the point of the proxy is all requests come in to the same ip/port, especially if the traffic is through a firewall. You don't have to allow different ports.
Last edited by elgrandeperro; 08-18-2022 at 10:15 AM.
You might want to check what IP node.js is using. I read the default is localhost /127.0.0.1 port 80. If so, you have to change the Vhost lines to:
from
<VirtualHost *:80>
to
<VirtualHost YOURIP:80>
For every instance, because one apache sees the wildcard it will add the wildcard bind. As I said before, I think you can have one at a more specific binding (localhost) and one at wilcard (* or 0.0.0.0) and I think it will work, but it creates an indeterminate situation depending on which was running which confuses testing.
As I said before, you can check the binding using netstat.
Thanks for your support now i successfully access django site and nodejs site but my native wordpress site not accessible its url redirect to port 8080 i did't mention 8080 anywhere my apache also running on defult 80 port wordpress vh below
<VirtualHost *:80>
ServerName hamsantech.com
ServerAdmin webmaster@localhost
ServerAlias www.hamsantech.com
DocumentRoot /var/www/html/hamsantech.com
<Directory /var/www/html/hamsantech.com>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Essentially, you are reversing the process from 8080 to 80. I assume your sitename is hamanstech.com, so you don't need to change that and since it seems to rewrite to that. I think it might rewrite things but also might grab content using the URL. So as long as it isn't localhost, it should work.
"During the WordPress installation process WordPress captures the hostname and port used to access the newly installed CMS. This information is stored in the backend MySQL database, and is used to force redirect requests to the correct hostname and port."
Its in the mysql database, not in config.php. You can change it via config.php, but the true value is in the database.
I'd change it in config.php, verify, then add it later to the db.
Last edited by elgrandeperro; 08-20-2022 at 03:00 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.