Gitlab error "422 Can't verify CSRF token authenticity" after migrating to new server

270 Views Asked by At

I just migrated my Gitlab instance to another server(debian) following Gitlab's official guides for backup and restore. All the configuration files are the same in both servers (nginx.conf, gitlab.rb, gitlab's vhost …). The backup/restore processes were successful based on gitlab's program outputs.

My Gitlab instance runs on existing nginx (not gitlab's one), the vhost configuration file for nginx is the same one in the official documentation.

I use let's encrypt for ssl certificates (same certificate for mydomain.com and gitlab.mydomain.com).

When I access the gitlab.mydomain.com I get redirected to giltab's login page, and after executing the request to login I get the error

422
The change you requested was rejected.

I also have an ssl certificate error in firefox (in the error page not the login page) Connection not secure: Parts of this page are not secure (such as images)

When I check the log file /var/log/gitlab/gitlab-rails/production_json.log I have

"exception.class": "ActionController::InvalidAuthenticityToken",
"exception.message": "Can't verify CSRF token authenticity.",

gitlab.rb :

external_url 'https://gitlab.mydomain.com'
pages_external_url 'https://pages.mydomain.com'
# Disable the built-in nginx
nginx['enable'] = false
# Disable the built-in puma
puma['enable'] = false
# Set the internal API URL
gitlab_rails['internal_api_url'] = 'https://gitlab.mydomain.com''
#disable status
nginx['status'] = {
  'enable' => false
}
# Define the web server process user (ubuntu/nginx)
web_server['external_users'] = ['www-data']

I can provide more information on the configuration if it helps, but it's basically the same configuration between the 2 servers.

screenshot of the error.

0

There are 0 best solutions below