JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

nginx 代理本地的html

wys521 2024-09-18 03:01:31 精选教程 29 ℃ 0 评论

编辑nginx.conf


Java代码

  1. server {
  2. listen 80;
  3. server_name localhost;

  4. #charset koi8-r;

  5. #access_log logs/host.access.log main;

  6. location / {
  7. root html; ## 指向nginx 安装目录下的html文件夹,看具体配置
  8. index noindex.htm;
  9. autoindex on;
  10. }

  11. location /www/ {
  12. root /home/admin/; ##会指向/home/admin/www
  13. autoindex on; ##会自动显示资源目录
  14. index noindex.htm;
  15. }



通过浏览器范围 localhost/www/index.htm,访问时出现403。

Nginx的error.log 报以下错误: *2658 open() “/xxx/xxxx(dir path)” failed (13: Permission denied)


确定为权限问题,在nginx.conf 中增加用户配置


  1. user admin users;



查看work process的所属用户


Html代码

  1. [admin@wuzhongarch ~]$ ps -ef | grep nginx
  2. root 12195 1 0 15:06 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/conf/nginx.conf
  3. admin 12196 12195 0 15:06 ? 00:00:00 nginx: worker process


文件目录的组和权限


Html代码

  1. [admin@wuzhongarch ~]$ ll | grep www
  2. drwxr-xr-x 4 admin users 4096 Feb 2 15:05 www/


这样就可以正常浏览访问了。。

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表