Ngnix Proxy Configration error

Codeless

Active member
Hi
on a client demand i was setting up xenforo on proxy servers . here is my setup diagram

5Wu9qzR.jpg


so if anyone check Example.com Who is and dns records its display proxies ip address

DNS Records of Example .com

-wZpJ7A8RB6HbWvAw04Ykg.png


but when use open example.com website works fine but when click on any url its become like 192.168.8.1:2021 instead of stay on domain link

here is my xenforo config

x7_mhbF8S3msIVQUzLv1dQ.png



and here is what i see when user click on link

hPuR2LS.png




and here is my Apache .htaccess config :

PHP:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    #Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example.\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>


also here is my Ngnix Proxy config

PHP:
server {
 listen 80 default;
 server_name www.example.com;
 rewrite ^ $scheme://www.example.com$request_uri permanent;
 root /var/www/html;
 index index.html;

 location / {
  proxy_pass http://192.168.8.1:2021/;
  root /var/www/html;
  proxy_redirect off;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
}


Please help me to fix this issue

i requested to @Brogan @MattW @ThemeHouse @Martok
 
If you require a reply from a member of staff, please submit a ticket from your customer area. However, this is mostly a server configuration issue so we may be limited in the support we can provide for it.

From a XF code point of view, the particular base URL you see for links is going to be coming from what we detect the full base path as, and this comes from the variables passed by the server itself:

PHP:
$host = $request->getServer('HTTP_HOST');
if (!$host)
{
   $host = $request->getServer('SERVER_NAME');
   $serverPort = intval($request->getServer('SERVER_PORT'));
   if ($serverPort && $serverPort != 80 && $serverPort != 443)
   {
      $host .= ':' . $serverPort;
   }
}
So it's either going to be coming from $_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME'].

You will have to explore what configuration options there are on the server side for proxying the correct URL through the whole request.
 
Top Bottom