Answer the question
In order to leave comments, you need to log in
The site works either on the intranet or on the internet. How to make friends between two networks so that it works both there and there?
Good afternoon, dear ones.
Tell me, in a home network of several computers, there is a machine on which a web server runs. Let's say the ip of this machine is 192.168.0.150 . The grid has an external IP address (84.xxx)
The problem is this: after I deployed a small wordpress site on the server? it normally works only from the internal network. I got into the router settings and forwarded port 27000 to 80 .
The problem hasn't been resolved. I am engaged in layout either from work or from a home network from another machine. It turns out crap, because. different urls all the time. I decided to link them (urls) to one namespace.
Set some mysite.demo and propipsal on the server in /etc/hosts
"192.168.0.150:80 mysite.demo
84.xxx:27000 mysite.demo
"
Everything worked fine
in the internal grid. The IP address is replaced by mysite.demo, and outside it turns out only to connect the html-carcass. Styles and stuff are not loaded. How to be?
Answer the question
In order to leave comments, you need to log in
what for to specify ports in hosts.
As far as I understand, you need an entry in hosts like
127.0.0.1 mysite.demo
in the router settings, forward 80 (external) to the desired internal one.
but as I understand it, wordpress will generate all relative links to resources (css, js) indicating the port of the internal network, that is, when you connect from the outside to the local machine, then in html there will be links like
mysite.demo:27000 and already from the browser (from outside) you try to download data from your site and it is no longer port 80 but 27000 and there will be an error.
to fix the links on the WordPress side, add the following code to wp-config.php
if( 'мой ip с интернета') {
define('WP_HOME','http://84.x.x.x:27000');
define('WP_SITEURL','http://84.x.x.x:27000');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question