How to remove :4567 from web address using Apache + mod_rewrite?

Solved Technical Support
  • I have a strange problem that I haven't been able to figure out.

    To get the :4567 out from the web address I'm doing this with .htaccess:

    RewriteCond %{HTTP_HOST} ^
    RewriteRule ^(.*)$$1 [P,L]

    Which works very well, better than the suggested ProxyPass solution (which I could not get working properly after spending some 3 hours at it).

    But my problem is that when I refresh the main page I get this:

    "/index.html cannot be found
    You have ended up on a page that does not exist. Return to main page."

    If I click the link to main page everything is roses and candy. But when ever I refresh the main page I get this error. I have no idea why it's even trying to find the index.html.

    Everything else works fine. Even entering the site for the first time loads the main page ok. It's just the refresh that bugs out.

    EDIT: I was wrong about the first load. It also bugs out.

    Any ideas what this is all about?

  • After some further thought I get the impression that when I try to open the the Nodebb main page:

    1. Apache handles the first call
    2. Apache asks by default for index.html
    3. index.html is not found because Nodebb doesn't roll that way.

    And thus the error.

    Now my guestion is how should I make the first call?

    Should I run nodebb.min.js from ~/nodebb/public/ or ... ?

  • Yeah, that was it. Solved it myself. Only took like 6 hours. I hate Apache configuration so much ...

    Here is the final solution for others in similar predicament:

    How to remove ":4567" from your address properly with Apache + mod_rewrite


    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^
    RewriteRule ^(.*)$ [NC,P,L]

    RewriteCond %{HTTP_HOST} ^
    RewriteRule ^(.*)$$1 [NC,P,L]

    Just replace the bolded addresses with your own domain, add into your root level .htaccess file and turn RewriteEngine on.

    Explanation of what happens here:

    The first line matches your address and if it contains or it replaces it with (on the seconds line) with

    (without these two lines you will get errors when you try to display the main page because Apache adds "index.html" by default to the request which gets then handled by Nodebb because of the two lines below these first two - but there is no index.html to handle because of the way Nodebb is built)

    NC = ignore case
    P = proxy, so that it is invisible to the user (they don't see the :4567)
    L = last rule, we stop if match is found

    Third line matches only your host without the trailing /somepage.html or /images/someimage.png or what ever. And the last line replaces that with and adds the rest of the address with $1

    This is rather useful if you are already running other websites besides the Nodebb forums with Apache on the same server. Because if you use the instructions in the documentation for ProxyPass you will get all of your web traffic rerouted with that configuration (unless you are running Nodebb from a subfolder, I think?)

    Well, I hope this is of some use.

    And remember to edit your config.json:

    "url": "",
    "port": "4567",

    If you find errors in any of this please post here.

Suggested Topics

| | | |