请看配置文件中的注释~
#user nobody; worker_processes 1; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; server_tokens off; sendfile on; keepalive_timeout 65; gzip on; upstream api { server 127.0.0.1:9178; } server { listen 8080;#监听8080端口 server_name localhost;#相当于IIS中的主机头 error_log logs/bookms.error.log; charset utf-8; location / { #默认跳转到http://127.0.0.1:9000 proxy_pass http://127.0.0.1:9000; } #当URL符合^\/(api)规则时,跳转到http://127.0.0.1:9178,即在upstream中配置的那个值 location ~ ^\/(api){ proxy_pass http://api; proxy_set_header X-Real-IP $remote_addr; client_max_body_size 100m; } } }
时间: 2024-12-27 23:24:55