horilla-opensource / horilla

Horilla is a free and open source HR software.
https://www.horilla.com/
GNU Lesser General Public License v2.1
83 stars 44 forks source link

nginx reverse proxy #151

Closed uckons closed 3 weeks ago

uckons commented 3 weeks ago

HI All, do you know ho to setup https reverse proxy using nginx, i been done setup only login page , when try to login i got error :

Reason given for failure:

Origin checking failed - https://hrms.adikarya.biz.id does not match any trusted origins.

In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django’s CSRF mechanism has not been used correctly. For POST forms, you need to ensure:

Your browser is accepting cookies. The view function passes a request to the template’s render method. In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL. If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data. The form has a valid CSRF token. After logging in in another browser tab or hitting the back button after a login, you may need to reload the page with the form, because the token is rotated after a login. You’re seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.

You can customize this page using the CSRF_FAILURE_VIEW setting.

horilla-opensource commented 3 weeks ago

Hi @uckons , In the settings.py (horilla/settings.py) file, please add your url in the CSRF_TRUSTED_ORIGINS.

In the settings.py, you'll find a line like below: env = environ.Env( DEBUG=(bool, True), SECRET_KEY=( str, "django-insecure-j8op9)1q8$1&0^s&p*_0%d#pr@w9qj@1o=3#@d=a(^@9@zd@%j", ), ALLOWED_HOSTS=(list, ["*"]), CSRF_TRUSTED_ORIGINS=(list, ["http://localhost:8000"]), )

Change the value from http://localhost:8000 to https://hrms.adikarya.biz.id and restart the service. Please let us know if this doesn't fix your issue.

With Regards, Team Horilla

uckons commented 3 weeks ago

hi @horilla-opensource amazing it works now

horilla-opensource commented 3 weeks ago

Hi @uckons , Can we please close this issue?

With Regards, Team Horilla

uckons commented 3 weeks ago

Sure @horilla-opensource closed this issue

uckons commented 3 weeks ago

Awesome