#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# another virtual host using mix of IP-, name-, and port-based configuration
#本地反向代理入口,动静分离
server {
listen 80;
server_name abc.com;
location ~ /(js|css|font|img) {
root D:\\efwork\\weinxin\\staticResource\\OfficialAccount;
}
//同一个域名根据后面的地址不同跳转不同的项目
location ^~/ctl/{
proxy_pass http://localhost:12100;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_pass_request_body on;
proxy_intercept_errors on;
}
//同一个域名根据后面的地址不同跳转不同的项目
location ^~/oac/{
proxy_pass http://localhost:10101;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_pass_request_body on;
proxy_intercept_errors on;
}
}
}
访问静态资源报错403
解决方法,将nginx.conf 头部的user nobody 改为user root
网友评论