nginx的使用(3)—— 配置一个间的反向代理

1.具体代码

  1. server {
  2. listen 80;
  3. server_name localhost;
  4. #charset koi8-r;
  5. #设置日志文件
  6. access_log logs/localhost.access.log;
  7. location / {
  8. root html;
  9. index index.html index.htm;
  10. proxy_pass http://localhost:8080/;
  11. }
  12. #error_page 404 /404.html;
  13. # redirect server error pages to the static page /50x.html
  14. #
  15. error_page 500 502 503 504 /50x.html;
  16. location = /50x.html {
  17. root html;
  18. }
  19. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  20. #
  21. #location ~ \.php$ {
  22. # proxy_pass http://127.0.0.1;
  23. #}
  24. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  25. #
  26. #location ~ \.php$ {
  27. # root html;
  28. # fastcgi_pass 127.0.0.1:9000;
  29. # fastcgi_index index.php;
  30. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  31. # include fastcgi_params;
  32. #}
  33. # deny access to .htaccess files, if Apache's document root
  34. # concurs with nginx's one
  35. #
  36. #location ~ /\.ht {
  37. # deny all;
  38. #}
  39. }

说明:在location代理中加入
proxy_pass http://localhost:8080/; 监控80端口所有请求代理到8080端口

2.效果截图

3.配置一个间的反向代理 - 图1