Project

General

Profile

Redmine Running on Nginx: 403 (Forbidden) and Uncaught ReferenceError on all pages

Added by J R over 4 years ago

I have a Redmine v4 instance running on Centos 7 with Nginx as the webserver. It was functioning perfectly fine for months, but then suddenly lost the ability to use its css. It still functions fine, but the pages are just plain text now. When I access the Console on Chrome I can see the following list of errors...

(index):13 GET http://redmine/stylesheets/jquery/jquery-ui-1.11.0.css?1586192448 net::ERR_ABORTED 403 (Forbidden)
(index):14 GET http://redmine/stylesheets/tribute-3.7.3.css?1586192449 net::ERR_ABORTED 403 (Forbidden)
(index):15 GET http://redmine/stylesheets/application.css?1586192449 net::ERR_ABORTED 403 (Forbidden)
(index):16 GET http://redmine/stylesheets/responsive.css?1586192449 net::ERR_ABORTED 403 (Forbidden)
(index):18 GET http://redmine/javascripts/jquery-2.2.4-ui-1.11.0-ujs-5.2.3.js?1586192448 net::ERR_ABORTED 403 (Forbidden)
(index):19 GET http://redmine/javascripts/tribute-3.7.3.min.js?1586192448 net::ERR_ABORTED 403 (Forbidden)
(index):20 GET http://redmine/javascripts/application.js?1586192449 net::ERR_ABORTED 403 (Forbidden)
(index):21 GET http://redmine/javascripts/responsive.js?1586192449 net::ERR_ABORTED 403 (Forbidden)
(index):24 Uncaught ReferenceError: $ is not defined
    at (index):24
favicon.ico:1 GET http://redmine/favicon.ico?1586192449 403 (Forbidden)

When I check for the source of the Uncaught ReferenceError it is the same section on every page.

<script>
//<![CDATA[
$(window).on('load', function(){ warnLeavingUnsaved('The current page contains unsaved text that will be lost if you leave this page.'); });
//]]>
</script>

This CDATA section is preceded by the lines producing the 403 Forbidden errors on css files.

<link rel="stylesheet" media="all" href="/stylesheets/jquery/jquery-ui-1.11.0.css?1586192448" />
<link rel="stylesheet" media="all" href="/stylesheets/tribute-3.7.3.css?1586192449" />
<link rel="stylesheet" media="all" href="/stylesheets/application.css?1586192449" />
<link rel="stylesheet" media="all" href="/stylesheets/responsive.css?1586192449" />

<script src="/javascripts/jquery-2.2.4-ui-1.11.0-ujs-5.2.3.js?1586192448"></script>
<script src="/javascripts/tribute-3.7.3.min.js?1586192448"></script>
<script src="/javascripts/application.js?1586192449"></script>
<script src="/javascripts/responsive.js?1586192449"></script>
<script>
//<![CDATA[
$(window).on('load', function(){ warnLeavingUnsaved('The current page contains unsaved text that will be lost if you leave this page.'); });
//]]>
</script>

I checked the permissions on the directories it seems to be pointing to but found no issues. I have also tried installing a fresh new instance of Redmine on a new VM running Centos and migrating the files and database, but the issue persists. Any advice on where to look next for debugging would be much appreciated.

Environment Info*

  Redmine version                4.1.1.stable
  Ruby version                   2.5.7-p206 (2019-10-01) [x86_64-linux]
  Rails version                  5.2.4.2
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
SCM:
  Filesystem                     
Redmine plugins:
  no plugin installed


Replies (1)

RE: Redmine Running on Nginx: 403 (Forbidden) and Uncaught ReferenceError on all pages - Added by J R over 4 years ago

It turns out it pays to pay attention to the SELinux warning messages. nginx was being denied by SELinux when trying to access a .ico file.

SELinux log message:

```
type=AVC msg=audit(##########.###:####): avc: denied { read } for pid=##### comm="nginx" name="favicon.ico" dev="dm-2" ino=######### scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:user_home_t:s0 tclass=file permissive=0
```

Following the troubleshooting, instructions from the SELinux console helped. I am unsure why the behavior changed. Perhaps there was a background update.

    (1-1/1)