Has anyone setup a reverse proxy for XenForo as a subfolder?

josh_b_and_b

New member
Trying to get XenForo to run in a folder on a domain, but the domain is not setup for PHP.

Like XenForo index at: mydomain.com/forums/

I'm hosting it over at forums.myseconddomain.com/forums but I don't want the user on this second domain, I want the user to browse on a subfolder of the primary domain.

1. The routing seems to be non-traditional, like "whats new" goes to: mydomain.com/forums/index.php?whats-new/

2. core-compiled.js Service worker registration failed: SecurityError: Failed to register a ServiceWorker: The origin of the provided scriptURL ('https://forums.myseconddomain.com') does not match the current origin ('https://mydomain.com').

Has anyone reverse proxied XenForo from a directory?
 
Problem 1 was fixed by messing with SEO url settings in admin.php

Problem 2 is still open.

Also...

When doing a reverse proxy with NextJS, we're trying to find out why some requests are often 301ing from the proxy to the host server.

301 redirects to:

Thinking we need to add in some headers?
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

The board settings are all set to https://www.mydomain.com/forums
 
Last edited:
Solved. Part of the problem was nextJS, however even with proper setup XenForo likes to redirect to the upstream/origin hostname, even though it's not specified anywhere in the files.

The solution involved:

  • turning off the trailing slash redirect on nextjs
  • routing both slash and non slash ending urls properly
  • setup a server-side worker to rewrite the response url to proper domain

The first 2 action items were due to nextJs being complicated, however the last item was XenForo-related weird behavior.
 
Back
Top Bottom