nginx配置同一個(gè)域名根據(jù)后面地址不同分配不同的項(xiàng)目

#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

  #本地反向代理入口,動(dòng)靜分離
server {
  listen 80;
  server_name abc.com;

  location ~ /(js|css|font|img) {
     root D:\\efwork\\weinxin\\staticResource\\OfficialAccount;

  }

//同一個(gè)域名根據(jù)后面的地址不同跳轉(zhuǎn)不同的項(xiàng)目
  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;
  }
//同一個(gè)域名根據(jù)后面的地址不同跳轉(zhuǎn)不同的項(xiàng)目
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;
  }

}

}

訪問靜態(tài)資源報(bào)錯(cuò)403
解決方法,將nginx.conf 頭部的user nobody 改為user root
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容