LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-18-2022, 10:04 AM   #16
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,173
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040

Quote:
*:80 grepbing.com (/etc/apache2/sites-enabled/grepbing.com.conf:1)
*:8080 hamsantech.com (/etc/apache2/sites-enabled/hamsantech.com.conf:1)
*:3000 kinderbakim.com (/etc/apache2/sites-enabled/kinderbakim.com.conf:1)
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
 
Old 08-18-2022, 10:11 AM   #17
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
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.
 
Old 08-19-2022, 12:06 AM   #18
Umeraf
LQ Newbie
 
Registered: Nov 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
I am still facing same steps after doing VH as mention above
 
Old 08-19-2022, 04:18 AM   #19
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,173
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
I am still facing same steps after doing VH as mention above
You are not helping much!

Anyway you should use something like that
Code:
<VirtualHost *:80>
#1st reverse proxy assuming django uses port 8081

ServerName grepbing.com
ProxyPreserveHost On
ProxyRequests Off
ProxyVia Full
ProxyPass / http://localhost:8081/
ProxyPassReverse / http://localhost:8081/
</VirtualHost>

<VirtualHost *:80>
#2nd reverse proxy for node.js

ProxyPreserveHost On
ProxyRequests Off
ProxyVia Full
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ServerName kinderbakim.com
</VirtualHost>

<VirtualHost *:80>
#A normal vhost for the wordpress site

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>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
 
Old 08-19-2022, 08:47 AM   #20
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
In each Vhost, I'd put in a separate log file, like:

ErrorLog ${APACHE_LOG_DIR}/nodejs.error.log
CustomLog ${APACHE_LOG_DIR}/nodejs.access.log combined

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.
 
Old 08-20-2022, 07:11 AM   #21
Umeraf
LQ Newbie
 
Registered: Nov 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
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>

ErrorLog ${APACHE_LOG_DIR}/word.error.log
CustomLog ${APACHE_LOG_DIR}/word.access.log combined
 
Old 08-20-2022, 08:03 AM   #22
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
You are saying, if you type in http://hamansantech.com it redirects to http://hamansantech.com:8080? Did you install WP on port 8080 originally?

Wordpress itself configures the install URL (sitename and port). So you have to undo this.

https://www.serverlab.ca/tutorials/l...for-wordpress/

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.
 
Old 08-20-2022, 02:23 PM   #23
Umeraf
LQ Newbie
 
Registered: Nov 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
Yes install wordpress on port 8080 now i want to wp listen on port 80 i check the config.php file but did't find url with port 8080
 
Old 08-20-2022, 02:58 PM   #24
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
Did you read the article fully:

"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.
 
Old 08-20-2022, 03:12 PM   #25
Umeraf
LQ Newbie
 
Registered: Nov 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
I change in database as well with the following query but no luck still redirect to 8080

update wp_options set option_value='http://localhost:80' where option_name='siteurl';

update wp_options set option_value='http://localhost:80' where option_name='home';
 
Old 08-21-2022, 01:15 AM   #26
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
Try to do the define in wp-config.php:

define('WPSITEURL','http://hamsantech.com/');
define('WPHOME','http://hamsantech.com/');
 
Old 08-21-2022, 12:49 PM   #27
Umeraf
LQ Newbie
 
Registered: Nov 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
Thanks for your help problem has been solved now.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Three Users, Three Window Managers - How? GNewbie Ubuntu 10 03-19-2007 01:23 AM
LXer: Sun Microsystems Delivers Three-in-One Punch to the Competition With World Record Results on Three Operating Systems, Including Solaris 10 LXer Syndicated Linux News 0 02-07-2006 09:46 PM
Three years later, three steps back RAnthony General 1 09-11-2004 04:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration