在计算机网络中,反向代理是代理服务器的一种。它根据客户端的请求,从后端的服务器上获取资源,然后再将这些资源返回给客户端。与前向代理不同,前向代理作为一个媒介将互联网上获取的资源返回给相关联的客户端,而反向代理是在服务器端作为代理使用,而不是客户端。
- server{
- listen 80;
- server_name 域名1;域名2;
- access_log access.log 文件路径;
- error_log error.log 文件路径;
-
- location / {
- proxy_redirect off;
- proxy_pass_request_headers on;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_pass http://127.0.0.1:nodejs 端口;
- }
-
- location /static {
- expires max;
- access_log off;
- root /path/to/webroot-pro;
- }
- }