nginx not serving admin static files?nginx issue with static files servingHow to serve Django admin media files on Bluehostnginx - serving static files, invoking PHP insteadNginx no static files after updateDjango doesn't find CSS files for admin pages using uWSGIWhy am I getting a 403 in attempting to access view-source:https://ccachicago.pragmatometer.com/admin/static/css/base.css?Enable nginx browser catching for specific urlHow to serve static files for multiple Django projects via nginx to same domainNginx static files not being servedServe Django Media Files via Nginx (Django/React/Nginx/Docker-Compose)
Are academic associations obliged to comply with the US government?
Is it possible to kill all life on Earth?
What if you don't bring your credit card or debit for incidentals?
The original word for a wild boar
If a massive object like Jupiter flew past the Earth how close would it need to come to pull people off of the surface?
How can I stop my presentation being derailed by audience questions?
The qvolume of an integer
Bringing Food from Hometown for Out-of-Town Interview?
Is the capacitor drawn or wired wrongly?
Asking bank to reduce APR instead of increasing credit limit
Applicants clearly not having the skills they advertise
How to properly maintain eye contact with people that have distinctive facial features?
arcpy.GetParameterAsText not passing arguments to script?
What is the purpose of std::forward()'s rvalue reference overload?
How can a single Member of the House block a Congressional bill?
Is American Express widely accepted in France?
How can I offer a test ride while selling a bike?
Is the world in Game of Thrones spherical or flat?
Why were the Night's Watch required to be celibate?
Can you use a concentration spell while using Mantle of Majesty?
Expenditure in Poland - Forex doesn't have Zloty
Beginner's snake game using PyGame
Does nuclear propulsion applied to military ships fall under civil or military nuclear power?
Are there regional foods in Westeros?
nginx not serving admin static files?
nginx issue with static files servingHow to serve Django admin media files on Bluehostnginx - serving static files, invoking PHP insteadNginx no static files after updateDjango doesn't find CSS files for admin pages using uWSGIWhy am I getting a 403 in attempting to access view-source:https://ccachicago.pragmatometer.com/admin/static/css/base.css?Enable nginx browser catching for specific urlHow to serve static files for multiple Django projects via nginx to same domainNginx static files not being servedServe Django Media Files via Nginx (Django/React/Nginx/Docker-Compose)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Clarification: The following error is onlyfor the admin static files, i.e. it is specific to the static files corresponding to the Django admin. The rest of the static files are working perfectly.
Problem
Basically, I cannot access the admin static files using the ngix server.
It does work with the micro server of Django, and the collectstatic is doing its job, meaning it is putting the files on the expected place in the static folder.
The urls are correct but I cannot access the admin static files directly, but the others I can. So, for example:
I am able to access this url (copying it in the browser):
myserver.com:8080/static/css/base/base.cssbut I am not able to access this other url (copying it in the browser):
myserver.com:8080/static/admin/css/admin.css
What have I tried?
It does work if I copy the admin/ directory structure into __other_admin_directory_name/__, and then I accessmyserver.com:8080/static/__other_admin_directory_name__/css/admin.css
Moreover,
- I checked permissions and everything is fine.
- I tried to change ADMIN_MEDIA_PREFIX = '/static/admin/' to ADMIN_MEDIA_PREFIX = '/static/other_admin_directory_name/', it doesn't work.
Finally, and it seems to be an important clue:
I tried to copy the admin/ directory structure into __admin_and_then_any_suffix/__. Then I cannot accessmyserver.com:8080/static/__admin_and_then_any_suffix/__/css/admin.css. So, if the name of the directory starts with admin (for example administration or admin2) then it doesn't work.
EDIT - added thanks to @sarnold observation:
The problem seems to be in the nginx configuration file /etc/nginx/sites-available/mysite
location /static/admin
alias /home/vl3/.virtualenvs/vl3/lib/python2.7/site-packages/django/contrib/admin/media/;
django nginx
migrated from stackoverflow.com Jun 29 '12 at 1:50
This question came from our site for professional and enthusiast programmers.
|
show 2 more comments
Clarification: The following error is onlyfor the admin static files, i.e. it is specific to the static files corresponding to the Django admin. The rest of the static files are working perfectly.
Problem
Basically, I cannot access the admin static files using the ngix server.
It does work with the micro server of Django, and the collectstatic is doing its job, meaning it is putting the files on the expected place in the static folder.
The urls are correct but I cannot access the admin static files directly, but the others I can. So, for example:
I am able to access this url (copying it in the browser):
myserver.com:8080/static/css/base/base.cssbut I am not able to access this other url (copying it in the browser):
myserver.com:8080/static/admin/css/admin.css
What have I tried?
It does work if I copy the admin/ directory structure into __other_admin_directory_name/__, and then I accessmyserver.com:8080/static/__other_admin_directory_name__/css/admin.css
Moreover,
- I checked permissions and everything is fine.
- I tried to change ADMIN_MEDIA_PREFIX = '/static/admin/' to ADMIN_MEDIA_PREFIX = '/static/other_admin_directory_name/', it doesn't work.
Finally, and it seems to be an important clue:
I tried to copy the admin/ directory structure into __admin_and_then_any_suffix/__. Then I cannot accessmyserver.com:8080/static/__admin_and_then_any_suffix/__/css/admin.css. So, if the name of the directory starts with admin (for example administration or admin2) then it doesn't work.
EDIT - added thanks to @sarnold observation:
The problem seems to be in the nginx configuration file /etc/nginx/sites-available/mysite
location /static/admin
alias /home/vl3/.virtualenvs/vl3/lib/python2.7/site-packages/django/contrib/admin/media/;
django nginx
migrated from stackoverflow.com Jun 29 '12 at 1:50
This question came from our site for professional and enthusiast programmers.
2
You forgot to include the relevant portions of yournginxconfiguration.
– sarnold
Jun 27 '12 at 23:27
This is a clean ubuntu 11.10 installation (it was working before in the same clean version) and I haven't touch the conf file but it seems you are right. There is something that seems to be the problem. I am editing my question...
– toto_tico
Jun 28 '12 at 0:03
@Carsten, maybe your link is wrong. [link](serveroverflow.com) does not exist
– toto_tico
Jun 28 '12 at 0:13
Is there a reason you need a specific location entry just for/static/admin? Wouldn't the standard '/static' cover it all? I just use a single:location /static/ alias /path/to/static/;
– jdi
Jun 28 '12 at 0:18
ok, i did the obvious here. I changed the path to the exact directory I have the files. It worked but I am worried, I don't think that is a line I should arbitrary change. This is a default configuration. I'll let you know exactly what is happening. Thanks!
– toto_tico
Jun 28 '12 at 0:25
|
show 2 more comments
Clarification: The following error is onlyfor the admin static files, i.e. it is specific to the static files corresponding to the Django admin. The rest of the static files are working perfectly.
Problem
Basically, I cannot access the admin static files using the ngix server.
It does work with the micro server of Django, and the collectstatic is doing its job, meaning it is putting the files on the expected place in the static folder.
The urls are correct but I cannot access the admin static files directly, but the others I can. So, for example:
I am able to access this url (copying it in the browser):
myserver.com:8080/static/css/base/base.cssbut I am not able to access this other url (copying it in the browser):
myserver.com:8080/static/admin/css/admin.css
What have I tried?
It does work if I copy the admin/ directory structure into __other_admin_directory_name/__, and then I accessmyserver.com:8080/static/__other_admin_directory_name__/css/admin.css
Moreover,
- I checked permissions and everything is fine.
- I tried to change ADMIN_MEDIA_PREFIX = '/static/admin/' to ADMIN_MEDIA_PREFIX = '/static/other_admin_directory_name/', it doesn't work.
Finally, and it seems to be an important clue:
I tried to copy the admin/ directory structure into __admin_and_then_any_suffix/__. Then I cannot accessmyserver.com:8080/static/__admin_and_then_any_suffix/__/css/admin.css. So, if the name of the directory starts with admin (for example administration or admin2) then it doesn't work.
EDIT - added thanks to @sarnold observation:
The problem seems to be in the nginx configuration file /etc/nginx/sites-available/mysite
location /static/admin
alias /home/vl3/.virtualenvs/vl3/lib/python2.7/site-packages/django/contrib/admin/media/;
django nginx
Clarification: The following error is onlyfor the admin static files, i.e. it is specific to the static files corresponding to the Django admin. The rest of the static files are working perfectly.
Problem
Basically, I cannot access the admin static files using the ngix server.
It does work with the micro server of Django, and the collectstatic is doing its job, meaning it is putting the files on the expected place in the static folder.
The urls are correct but I cannot access the admin static files directly, but the others I can. So, for example:
I am able to access this url (copying it in the browser):
myserver.com:8080/static/css/base/base.cssbut I am not able to access this other url (copying it in the browser):
myserver.com:8080/static/admin/css/admin.css
What have I tried?
It does work if I copy the admin/ directory structure into __other_admin_directory_name/__, and then I accessmyserver.com:8080/static/__other_admin_directory_name__/css/admin.css
Moreover,
- I checked permissions and everything is fine.
- I tried to change ADMIN_MEDIA_PREFIX = '/static/admin/' to ADMIN_MEDIA_PREFIX = '/static/other_admin_directory_name/', it doesn't work.
Finally, and it seems to be an important clue:
I tried to copy the admin/ directory structure into __admin_and_then_any_suffix/__. Then I cannot accessmyserver.com:8080/static/__admin_and_then_any_suffix/__/css/admin.css. So, if the name of the directory starts with admin (for example administration or admin2) then it doesn't work.
EDIT - added thanks to @sarnold observation:
The problem seems to be in the nginx configuration file /etc/nginx/sites-available/mysite
location /static/admin
alias /home/vl3/.virtualenvs/vl3/lib/python2.7/site-packages/django/contrib/admin/media/;
django nginx
django nginx
edited Dec 31 '17 at 15:46
toto_tico
asked Jun 27 '12 at 23:13
toto_ticototo_tico
116116
116116
migrated from stackoverflow.com Jun 29 '12 at 1:50
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Jun 29 '12 at 1:50
This question came from our site for professional and enthusiast programmers.
2
You forgot to include the relevant portions of yournginxconfiguration.
– sarnold
Jun 27 '12 at 23:27
This is a clean ubuntu 11.10 installation (it was working before in the same clean version) and I haven't touch the conf file but it seems you are right. There is something that seems to be the problem. I am editing my question...
– toto_tico
Jun 28 '12 at 0:03
@Carsten, maybe your link is wrong. [link](serveroverflow.com) does not exist
– toto_tico
Jun 28 '12 at 0:13
Is there a reason you need a specific location entry just for/static/admin? Wouldn't the standard '/static' cover it all? I just use a single:location /static/ alias /path/to/static/;
– jdi
Jun 28 '12 at 0:18
ok, i did the obvious here. I changed the path to the exact directory I have the files. It worked but I am worried, I don't think that is a line I should arbitrary change. This is a default configuration. I'll let you know exactly what is happening. Thanks!
– toto_tico
Jun 28 '12 at 0:25
|
show 2 more comments
2
You forgot to include the relevant portions of yournginxconfiguration.
– sarnold
Jun 27 '12 at 23:27
This is a clean ubuntu 11.10 installation (it was working before in the same clean version) and I haven't touch the conf file but it seems you are right. There is something that seems to be the problem. I am editing my question...
– toto_tico
Jun 28 '12 at 0:03
@Carsten, maybe your link is wrong. [link](serveroverflow.com) does not exist
– toto_tico
Jun 28 '12 at 0:13
Is there a reason you need a specific location entry just for/static/admin? Wouldn't the standard '/static' cover it all? I just use a single:location /static/ alias /path/to/static/;
– jdi
Jun 28 '12 at 0:18
ok, i did the obvious here. I changed the path to the exact directory I have the files. It worked but I am worried, I don't think that is a line I should arbitrary change. This is a default configuration. I'll let you know exactly what is happening. Thanks!
– toto_tico
Jun 28 '12 at 0:25
2
2
You forgot to include the relevant portions of your
nginx configuration.– sarnold
Jun 27 '12 at 23:27
You forgot to include the relevant portions of your
nginx configuration.– sarnold
Jun 27 '12 at 23:27
This is a clean ubuntu 11.10 installation (it was working before in the same clean version) and I haven't touch the conf file but it seems you are right. There is something that seems to be the problem. I am editing my question...
– toto_tico
Jun 28 '12 at 0:03
This is a clean ubuntu 11.10 installation (it was working before in the same clean version) and I haven't touch the conf file but it seems you are right. There is something that seems to be the problem. I am editing my question...
– toto_tico
Jun 28 '12 at 0:03
@Carsten, maybe your link is wrong. [link](serveroverflow.com) does not exist
– toto_tico
Jun 28 '12 at 0:13
@Carsten, maybe your link is wrong. [link](serveroverflow.com) does not exist
– toto_tico
Jun 28 '12 at 0:13
Is there a reason you need a specific location entry just for
/static/admin? Wouldn't the standard '/static' cover it all? I just use a single: location /static/ alias /path/to/static/; – jdi
Jun 28 '12 at 0:18
Is there a reason you need a specific location entry just for
/static/admin? Wouldn't the standard '/static' cover it all? I just use a single: location /static/ alias /path/to/static/; – jdi
Jun 28 '12 at 0:18
ok, i did the obvious here. I changed the path to the exact directory I have the files. It worked but I am worried, I don't think that is a line I should arbitrary change. This is a default configuration. I'll let you know exactly what is happening. Thanks!
– toto_tico
Jun 28 '12 at 0:25
ok, i did the obvious here. I changed the path to the exact directory I have the files. It worked but I am worried, I don't think that is a line I should arbitrary change. This is a default configuration. I'll let you know exactly what is happening. Thanks!
– toto_tico
Jun 28 '12 at 0:25
|
show 2 more comments
2 Answers
2
active
oldest
votes
My suggestions:
Use django 1.3+ (and ADMIN_MEDIA_PREFIX is deprecated now)
Set both
STATIC_URLandSTATIC_ROOTin your settings.pyDefine just a single static entry in your nginx conf (with trailing slashes). No need for a second one that addresses
static/admin/:location /static/
alias /path/to/static/;Use
collectstaticwhich should collect admin -> static/admin. It will live under the same location as all the rest of your collected static media.python manage.py collectstatic
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
1
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
|
show 1 more comment
I have the same problem. My nginx server on Centos 7.6 can't access to static folder in path /home/user/app/mysyte/static/. In /var/log/nginx/error.log same error
open() "/home/user/app/mysyte/static/*.css" failed (13: Permission denied)
For solving and understanding this problem :=*
- run command
getenforce - if enforcing -
cat /var/log/audit/audit.log | grep nginx
for me string with errrors looks like
type=AVC msg=audit(1558033633.723:201): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
type=SYSCALL msg=audit(1558033633.723:201): arch=c000003e syscall=2 success=no exit=-13 a0=564f710dd55d a1=800 a2=0 a3=68632f656d6f682f items=0 ppid=7757 pid=7758 auid=4294967295 uid=998 gid=996 euid=998 suid=998 fsuid=998 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:httpd_t:s0 key=(null)
copy id of audit msg 1558033633.723:201
- run command
grep yours_audit_id /var/log/audit/audit.log | audit2why
output for me
[root@uwsgi ~]# grep 1558034479.384:221 /var/log/audit/audit.log | audit2why
type=AVC msg=audit(1558034479.384:221): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
Was caused by:
The boolean httpd_read_user_content was set incorrectly.
Description:
Allow httpd to read user content
Allow access by executing:
# setsebool -P httpd_read_user_content 1
So as you can see answer here setsebool -P httpd_read_user_content 1 when you run this command you see your static content
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f403264%2fnginx-not-serving-admin-static-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
My suggestions:
Use django 1.3+ (and ADMIN_MEDIA_PREFIX is deprecated now)
Set both
STATIC_URLandSTATIC_ROOTin your settings.pyDefine just a single static entry in your nginx conf (with trailing slashes). No need for a second one that addresses
static/admin/:location /static/
alias /path/to/static/;Use
collectstaticwhich should collect admin -> static/admin. It will live under the same location as all the rest of your collected static media.python manage.py collectstatic
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
1
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
|
show 1 more comment
My suggestions:
Use django 1.3+ (and ADMIN_MEDIA_PREFIX is deprecated now)
Set both
STATIC_URLandSTATIC_ROOTin your settings.pyDefine just a single static entry in your nginx conf (with trailing slashes). No need for a second one that addresses
static/admin/:location /static/
alias /path/to/static/;Use
collectstaticwhich should collect admin -> static/admin. It will live under the same location as all the rest of your collected static media.python manage.py collectstatic
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
1
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
|
show 1 more comment
My suggestions:
Use django 1.3+ (and ADMIN_MEDIA_PREFIX is deprecated now)
Set both
STATIC_URLandSTATIC_ROOTin your settings.pyDefine just a single static entry in your nginx conf (with trailing slashes). No need for a second one that addresses
static/admin/:location /static/
alias /path/to/static/;Use
collectstaticwhich should collect admin -> static/admin. It will live under the same location as all the rest of your collected static media.python manage.py collectstatic
My suggestions:
Use django 1.3+ (and ADMIN_MEDIA_PREFIX is deprecated now)
Set both
STATIC_URLandSTATIC_ROOTin your settings.pyDefine just a single static entry in your nginx conf (with trailing slashes). No need for a second one that addresses
static/admin/:location /static/
alias /path/to/static/;Use
collectstaticwhich should collect admin -> static/admin. It will live under the same location as all the rest of your collected static media.python manage.py collectstatic
answered Jun 28 '12 at 0:29
jdijdi
33125
33125
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
1
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
|
show 1 more comment
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
1
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
I am using django 1.4. I have the three of them: ADMIN_MEDIA_PREFIX, STATIC_URL, STATIC_ROOT. The collectstatic is working well as I explained. The only thing I am still curious about is where that ...python2.7/site-packages/...static/ came from...
– toto_tico
Jun 28 '12 at 0:36
1
1
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
Well you can get rid of ADMIN_MEDIA_PREFIX. Its no longer in use. That and the reference to the site-packages is all OLD django stuff. Its not used in 1.3+. admin will end up in the static root.
– jdi
Jun 28 '12 at 0:37
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
perfect! As I said this was a clean ubuntu 11.10 / nginx installation. Do you mind to do a small edition in your answer adding another step: delete the location /static/admin/ ... section
– toto_tico
Jun 28 '12 at 0:41
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
Why? Did your default nginx conf somehow come with that entry in the first place? I was listing sort of a ground up set of items that would apply to anyone. If it isn't there then you probably shouldn't have it.
– jdi
Jun 28 '12 at 0:51
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
well, that's exactly what i mean. This is a clean installation. I never touched that file before. I solved the problem deleting that section in the file.
– toto_tico
Jun 28 '12 at 1:10
|
show 1 more comment
I have the same problem. My nginx server on Centos 7.6 can't access to static folder in path /home/user/app/mysyte/static/. In /var/log/nginx/error.log same error
open() "/home/user/app/mysyte/static/*.css" failed (13: Permission denied)
For solving and understanding this problem :=*
- run command
getenforce - if enforcing -
cat /var/log/audit/audit.log | grep nginx
for me string with errrors looks like
type=AVC msg=audit(1558033633.723:201): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
type=SYSCALL msg=audit(1558033633.723:201): arch=c000003e syscall=2 success=no exit=-13 a0=564f710dd55d a1=800 a2=0 a3=68632f656d6f682f items=0 ppid=7757 pid=7758 auid=4294967295 uid=998 gid=996 euid=998 suid=998 fsuid=998 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:httpd_t:s0 key=(null)
copy id of audit msg 1558033633.723:201
- run command
grep yours_audit_id /var/log/audit/audit.log | audit2why
output for me
[root@uwsgi ~]# grep 1558034479.384:221 /var/log/audit/audit.log | audit2why
type=AVC msg=audit(1558034479.384:221): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
Was caused by:
The boolean httpd_read_user_content was set incorrectly.
Description:
Allow httpd to read user content
Allow access by executing:
# setsebool -P httpd_read_user_content 1
So as you can see answer here setsebool -P httpd_read_user_content 1 when you run this command you see your static content
add a comment |
I have the same problem. My nginx server on Centos 7.6 can't access to static folder in path /home/user/app/mysyte/static/. In /var/log/nginx/error.log same error
open() "/home/user/app/mysyte/static/*.css" failed (13: Permission denied)
For solving and understanding this problem :=*
- run command
getenforce - if enforcing -
cat /var/log/audit/audit.log | grep nginx
for me string with errrors looks like
type=AVC msg=audit(1558033633.723:201): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
type=SYSCALL msg=audit(1558033633.723:201): arch=c000003e syscall=2 success=no exit=-13 a0=564f710dd55d a1=800 a2=0 a3=68632f656d6f682f items=0 ppid=7757 pid=7758 auid=4294967295 uid=998 gid=996 euid=998 suid=998 fsuid=998 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:httpd_t:s0 key=(null)
copy id of audit msg 1558033633.723:201
- run command
grep yours_audit_id /var/log/audit/audit.log | audit2why
output for me
[root@uwsgi ~]# grep 1558034479.384:221 /var/log/audit/audit.log | audit2why
type=AVC msg=audit(1558034479.384:221): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
Was caused by:
The boolean httpd_read_user_content was set incorrectly.
Description:
Allow httpd to read user content
Allow access by executing:
# setsebool -P httpd_read_user_content 1
So as you can see answer here setsebool -P httpd_read_user_content 1 when you run this command you see your static content
add a comment |
I have the same problem. My nginx server on Centos 7.6 can't access to static folder in path /home/user/app/mysyte/static/. In /var/log/nginx/error.log same error
open() "/home/user/app/mysyte/static/*.css" failed (13: Permission denied)
For solving and understanding this problem :=*
- run command
getenforce - if enforcing -
cat /var/log/audit/audit.log | grep nginx
for me string with errrors looks like
type=AVC msg=audit(1558033633.723:201): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
type=SYSCALL msg=audit(1558033633.723:201): arch=c000003e syscall=2 success=no exit=-13 a0=564f710dd55d a1=800 a2=0 a3=68632f656d6f682f items=0 ppid=7757 pid=7758 auid=4294967295 uid=998 gid=996 euid=998 suid=998 fsuid=998 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:httpd_t:s0 key=(null)
copy id of audit msg 1558033633.723:201
- run command
grep yours_audit_id /var/log/audit/audit.log | audit2why
output for me
[root@uwsgi ~]# grep 1558034479.384:221 /var/log/audit/audit.log | audit2why
type=AVC msg=audit(1558034479.384:221): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
Was caused by:
The boolean httpd_read_user_content was set incorrectly.
Description:
Allow httpd to read user content
Allow access by executing:
# setsebool -P httpd_read_user_content 1
So as you can see answer here setsebool -P httpd_read_user_content 1 when you run this command you see your static content
I have the same problem. My nginx server on Centos 7.6 can't access to static folder in path /home/user/app/mysyte/static/. In /var/log/nginx/error.log same error
open() "/home/user/app/mysyte/static/*.css" failed (13: Permission denied)
For solving and understanding this problem :=*
- run command
getenforce - if enforcing -
cat /var/log/audit/audit.log | grep nginx
for me string with errrors looks like
type=AVC msg=audit(1558033633.723:201): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
type=SYSCALL msg=audit(1558033633.723:201): arch=c000003e syscall=2 success=no exit=-13 a0=564f710dd55d a1=800 a2=0 a3=68632f656d6f682f items=0 ppid=7757 pid=7758 auid=4294967295 uid=998 gid=996 euid=998 suid=998 fsuid=998 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:httpd_t:s0 key=(null)
copy id of audit msg 1558033633.723:201
- run command
grep yours_audit_id /var/log/audit/audit.log | audit2why
output for me
[root@uwsgi ~]# grep 1558034479.384:221 /var/log/audit/audit.log | audit2why
type=AVC msg=audit(1558034479.384:221): avc: denied read for pid=7758 comm="nginx" name="responsive.css" dev="dm-0" ino=17312394 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
Was caused by:
The boolean httpd_read_user_content was set incorrectly.
Description:
Allow httpd to read user content
Allow access by executing:
# setsebool -P httpd_read_user_content 1
So as you can see answer here setsebool -P httpd_read_user_content 1 when you run this command you see your static content
answered May 16 at 19:26
N. TurshievN. Turshiev
211
211
add a comment |
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f403264%2fnginx-not-serving-admin-static-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
You forgot to include the relevant portions of your
nginxconfiguration.– sarnold
Jun 27 '12 at 23:27
This is a clean ubuntu 11.10 installation (it was working before in the same clean version) and I haven't touch the conf file but it seems you are right. There is something that seems to be the problem. I am editing my question...
– toto_tico
Jun 28 '12 at 0:03
@Carsten, maybe your link is wrong. [link](serveroverflow.com) does not exist
– toto_tico
Jun 28 '12 at 0:13
Is there a reason you need a specific location entry just for
/static/admin? Wouldn't the standard '/static' cover it all? I just use a single:location /static/ alias /path/to/static/;– jdi
Jun 28 '12 at 0:18
ok, i did the obvious here. I changed the path to the exact directory I have the files. It worked but I am worried, I don't think that is a line I should arbitrary change. This is a default configuration. I'll let you know exactly what is happening. Thanks!
– toto_tico
Jun 28 '12 at 0:25