I’ve recently migrated a journal into Docker-based OJS and have difficulties in configuring URLs.
location ~ / {
proxy_pass https://127.0.0.1:8491;
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;
}
This means that jota.website is really only working as an alias of journals.docuracy.co.uk, and calls to https://jota.website are rewritten as https://jota.website/jota; other pages all have an unwanted “/jota/” in their urls. The root administration pages are available on both urls. I want to restrict the administration to journals.docuracy.co.uk only, and remove the unwanted “/jota” from the urls for that journal.
Having tried various settings for base_url[jota]
and base_url[index]
, none of which had the desired effect (either no effect, “too many redirects”, or server 500 errors), I don’t think these settings are relevant.
The documentation suggests that the Docker image has some inbuilt URL rewriting, and that I might need to modify its behaviour with custom .htaccess
directives. Can anyone suggest a solution, please?
Hello @Stephen_Gadd, I hope I can help you, since I am using an OJS Dockerized environment with NGINX reverse proxy.
However, I didn’t understand exactly what is your problem.
I am assuming that you have this Plesk/NGINX barebones trying to redirect to OJS inside Docker, and your running container have a map 8491:443. Check if you can access it directly, a curl from the host machine to https://127.0.0.1:8491
. If so, it should work…
Your configuration of reverse proxy seems good for me, and I did not need to configure my .htaccess with this kind of configuration.
Is the https://127.0.0.1:8491
the right address to put there? I cannot access the address https://journals.docuracy.co.uk:8491 (is it blocked to outside?)
Keep in mind that the ojs.config.inc.php
should have the 127.0.0.1 in the allowed_hosts, or you may prefer to redirect using domain.
Thanks for your reply, Henrique. I didn’t explain very clearly that the Nginx settings do allow the journal to be viewed: I simply want to hide part of the path which is displayed in the browser navigation bar, so for example instead of “https://jota.website/jota/contact” we would see only “https://jota.website/contact”.
Oh now I see, thanks God I said it should work haha
I didn’t configure it here (to remove the name of the journal), but I believe you can achieve it by puting in the .htaccess , similar to the index.php removal:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/jota/(.*)$
RewriteRule ^jota/(.*)$ /$1 [L,R=301]
Have a look at this too: Multi-domain rewrite rules problems
Thanks again, Henrique, much appreciated.
However, I’ve tried your suggestion and many variations in the apache.htaccess
file, but all result in 404 Not Found errors.
My latest effort is based on the realisation that (for example) if anyone types “https://jota.website/contact” in their browser, content needs to be served from “/jota/contact”:
RewriteEngine On
# Check if the host is jota.website
RewriteCond %{HTTP_HOST} ^(www\.)?jota\.website$ [NC]
# Redirect all requests starting with / to /jota/
RewriteCond %{REQUEST_URI} !^/jota/
RewriteRule ^(.*)$ /jota/$1 [L,R=301]
… this rewrites the URL to “https://jota.website/jota/contact” in the browser bar (defeating the point of trying to hide the “jota/” part of the URL), and results in a 404 Not Found error.
I have a growing sense that editing the apache.htaccess
file is not going to provide a solution, but that there needs to be some modification of the php code or perhaps the configuration file, but would be happy to be proved wrong!
1 Like