-1

I have installed Centos 6.7 on my virtual box along with Gitlab. I set up gitlab to listen on port 8081. Then I set up nginx to listen on port 80. However after googling for hours and tried some solutions I still get 403 when i tried to access my web page.

I put my index.html file in /var/www/nginxsite.com/public_html directory and change the owner and file permission to look like this:

dx-xr-xr-x root root /
dx-xr-xr-x root root /var
drwxr-xr-x nginx nginx /www
drwxr-xr-x nginx nginx /nginxsite.com
drwxr-xr-x nginx nginx /public_html
drwxr-xr-x nginx nginx /index.html

Here's my /etc/nginx/sites-available/nginxsite.com.conf configuration file:

server{
    listen 80;
    server_name nginxsite.com www.nginxsite.com
    location / {
        root /var/www/nginxsite.com/public_html;
        index index.html index.htm index.php;
        try files $uri $uri/ =404;
    }
    error page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
}

then in my host machine (ubuntu 14.04) I added these two line on /etc/hosts file:

192.168.1.130 my.gitlab.com
192.168.1.130 nginxsite.com

Any advice for me guys? Is there any error I made on the config? thanks

under5hell
  • 109
  • 5
  • Check the nginx error log, and the system audit log. – Michael Hampton Nov 28 '15 at 16:52
  • I got [error] 4569#0 "/var/www/nginxsite.com/public_html/index.html" is forbidden (13: permission denied) I think it's related to file permission, I followed this article http://nginxlibrary.com/403-forbidden-error/ except i change the user to nginx instead of www-data because some people said it must be the user who run nginx which is in my system is user nginx. I really wonder why i still get that 403 response. – under5hell Nov 28 '15 at 16:59
  • 2
    Read the rest of my previous comment. – Michael Hampton Nov 28 '15 at 17:06
  • I managed to solve it by following your comment. I will post the answer for my own question. thanks :) – under5hell Nov 28 '15 at 17:41
  • 1
    Beware, if your answer says "disable SELinux" you will get a lot of downvotes. You should not be disabling SELinux. – Michael Hampton Nov 28 '15 at 17:46

1 Answers1

1

Thanks for @Michael Hampton for the comment.

It turned out that the SElinux applied much stricter security permission to nginx since Centos 6.6. The following command solved my problem.

semanage fcontext -a -t httpd_sys_content_t /var/www/*
restorecon -Rv /var/www/*

Actually there are two ways to deal with this problem, For further reference see this useful article: https://www.nginx.com/blog/nginx-se-linux-changes-upgrading-rhel-6-6/#gs.iz_rbNA

under5hell
  • 109
  • 5