nginx部署完项目提示403
检查selinux配置,需要禁止selinux。
检查nginx运行账号是否有权限访问项目目录
检查index 配置中是否包含项目主页
nginx只允许域名不允许ip
1
2
3
4
5
6
7
8
9
10
11
12server{
listen 8080;
server_name nginx.myi-cloud.com;
root /var/www/html/study;
location /{
index index.html;
}
}
server {
listen 8080 default_server;
server_name _;
return 403;}
配置https
1
2
3
4
5
6
7
8
9server {
listen 443 ssl;
server_name nginx.myi-cloud.com;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.pem;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_session_cache shared:sslcache:20m;
ssl_session_timeout 10m;
}配置网页密码认证
1
2
3
4
5
6
7
8
9
10
11
12
13yum -y install httpd-tools
htpasswd -c -m .htpasswd habi
server{
listen 8080;
server_name nginx.myi-cloud.com;
root /var/www/html/study;
auth_basic "Please input password";
auth_basic_user_file /etc/nginx/.htpasswd;
location /{
index index.html;
}
}