default.conf
配置如下:
server { listen 80; server_name 127.0.0.1; error_page 500 502 503 504 /50x.html; location / { root /usr/share/nginx/html; index index.html index.htm; } location /api { proxy_pass http://127.0.0.1:5000; proxy_set_header X-Real-IP $remote_addr; } location /baidu { return 302 https://www.baidu.com$request_uri; } }
运行状态:
$ ps -ef |grep nginx root 31126 1 0 02:42 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 31127 31126 0 02:42 ? 00:00:00 nginx: worker process root 31155 13304 0 02:46 ? 00:00:00 /opt/appnode/agent/apps/nginx/anapp-nginx root 31212 31187 0 02:51 pts/0 00:00:00 grep --color=auto nginx
检查配置文件:
$ nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful
潇潇雨雨