Boa tarde pessoal,
Estou dando manutenção em uma revista em OJS (Versão 3.3.0-6) que está hopedada em um hosting.
Temos o site funcionando perfeitamente apenas em “http” (sem ativar o ssl), porém ao ativar o “https” o site desconfigura totalmente.
Já limpei cache, forcei o https no config.ini.php, adicionei um htaccess com redirecionamento para https, acionei o suporte do servidor de hospedagens, reiniciei o apache (via cliques) pois o servidor não permite fazer muitas coisas e nada resolve!!!
A equipe de suporte diz que o OJS está configurado de “forma mista” e eu tenho que corrigir isso “na mão”, mas não entendem que não customizamos códigos no Ojs.
Poderia até deixar como está, mas para ativar o ORCID, necessita de https!
Alguém teria alguma dica para poder resolver esse problema (a não ser mudar de servidor de host)?
Descobri que se clicar no inspetor do Firefox - inspetor (Q), consigo ver várias entradas do
com http (sem ssl)
Se mudar esta linha para https a configuração o css é lido corretamente: href=“http://www.revistaedugeo.com.br/ojs-3.3.0-6/index.php?journal=revistaedugeo&component=page.page&op=css&name=stylesheet ”
O problema é… onde estão estas entradas que não encontro?
Atenciosamente
Augusto Torres
@Augusto_Torres ,
tente colocar essa diretiva no Virtual host do Apache ou no arquivo .htaccess:
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
Referência:
opened 06:40PM - 10 Mar 21 UTC
Housekeeping:1:Todo
**Describe the problem you would like to solve**
Over httpS, when you are beh… ind a reverse proxy/loadbalancer or on complex networks architectures OJS have some trouble to discover the right protocol and it could generate some different issues like:
- Infinite redirection loops (ERR_TOO_MANY_REDIRECTS)
- Mixed content (http & httpS).
If httpS in forced in function `getProtcolol()` at "lib/pkp/classes/core/PKPRequest.inc.php" all problems are gone...
**Describe the solution you'd like**
This is supossed to be fixed with protocol relative URLs (allowProtocolRelative directive) but this is not yet full implemented in OJS... and (according to Alec) "We can't just enable protocol-relative URLs globally because of URLs that are delivered to outside mechanisms, e.g. API interactions, emails, etc."
So an alternative (and also to make OJS more flexible) the easiest solution is letting OJS honor the protocol specified at HTTP_X_FORWARDED_PROTO (if exists) instead of keep asking about the protocol to SCRIPT_URI.
It could be done here:
https://github.com/pkp/pkp-lib/blob/c5f40d7d390d0aedb9a4f9063914652aa6e3dc6c/classes/core/PKPRequest.inc.php#L351
Adding a condition to check if "HTTP_X_FORWARDED_PROTO" exists, and if yes, set the protocol to be whatever you find in the variable.
**What I tried?**
In my specific case, the problem was a reverse proxy (traefik) converting http petitions to httpS, so I tried with:
- base_url with http.
- base_url with httpS.
- base_url with relative protocol.
- setting base_url[index] and/or [myJournal].
- setting base_url to relative protocol.
- setting force_ssl to On.
All cases except the last one, results in "Mixed content" due JS references.
Last one (force_ssl) falls in an "infinite redirection loop" because "OJS sees an HTTP request (not knowing it’s coming from the reverse-proxy) and redirects the browser to the HTTPS location. So the browser makes a new request (using HTTPS as before) to the reverse-proxy resulting in a new HTTP request to the OJS backend which redirects to HTTPS again. And so on and so forth."
When protcolo is forced to httpS in getProtocol() ("lib/pkp/classes/core/PKPRequest.inc.php") problems are gone...
**Who is asking for this feature?**
- System administrators with a complex architecture.
- People installing their OJS in some hosting companies.
- Docker based architectures...
**Additional information**
Variations of this same issue are described here:
- https://forum.pkp.sfu.ca/t/ojs-3-2-0-ojs-generates-protocol-relative-urls-in-notification-e-mails/59688/16?u=marc
- https://forum.pkp.sfu.ca/t/ojs-3-behind-reverse-proxy-how-to-achieve/25055/17
- https://forum.pkp.sfu.ca/t/ojs-https-configuration/6679
- https://forum.pkp.sfu.ca/t/force-ssl-on-leads-to-err-too-many-redirects/45169
- https://forum.pkp.sfu.ca/t/http-https-ssl-cloudflare-ojs-3-1-2-1-this-request-has-been-blocked/54650
And also in the following github issues:
- https://github.com/pkp/pkp-lib/issues/1504
- https://github.com/pkp/pkp-lib/issues/5002
Example of mixed content:

Boa tarde @diegojmacedo
Vou tentar amanhã! O servidor de hospedagem é tão ruim que nem pelo painel deles estou conseguindo acessar o conteúdo!
Me disseram para adicionar essas entradas na pasta home do ojs:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sem esta linha que me indicou:
SetEnvIf X-Forwarded-Proto “^https$” HTTPS=on
Vou tentar adicionar na última linha, antes do “/IFModule” para ver se dá certo.
Obrigado por enquanto…
Depois retorno o resultado
Att
Augusto
1 curtida
Bom dia @diegojmacedo ,
Funcionou bem inserindo esta linha que me passou, ficou assim o arquivo .htaccess :
Muito obrigado pela dica.
Att
Augusto Torres
2 curtidas
Olá, @Augusto_Torres , bom que deu certo!!
só complementando, a diretiva SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
pode ficar fora da condição <ifModule mod_rewrite.c>
. Pois para aplicar essa diretiva, não é necessário do módulo rewrite.
1 curtida
Entendi!
Como eu estava pensando em redirecionar todas as chamadas para https, segui a dica do provedor, também adicionei esta linha.
Vou anotar aqui para para não passar mais sufoco!
Obrigado novamente
Att
Augusto
2 curtidas