1. server {
  2. listen 80;
  3. server_name 127.0.0.1;
  4. location / {
  5. proxy_pass http://ip:port
  6. }
  7. }

根据标识反向代理到不同服务

  1. server {
  2. listen 80;
  3. server_name www.elk.com;
  4. location /kibana/ {
  5. proxy_pass http://ip:5601;
  6. }
  7. location /elasticsearch/ {
  8. proxy_pass http://ip:9200;
  9. }
  10. }

wordpress

  1. upstream wordpress {
  2. server ip;
  3. }
  4. server {
  5. listen 80;
  6. server_name www.wordpress.com;
  7. location / {
  8. proxy_pass http://wordpress;
  9. client_max_body_size 1000m;
  10. proxy_set_header terminal_id $http_terminal_id;
  11. proxy_set_header Host $host:$server_port;
  12. proxy_set_header X_Read_IP $remote_addr;
  13. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14. proxy_set_header X-Forwarded-Host $host;
  15. proxy_set_header X-Forwarded-Server $host;
  16. proxy_set_header X-Forwarded-Proto $scheme;
  17. }
  18. # 静态资源
  19. location ~ .* {
  20. proxy_pass http://wordpress;
  21. proxy_set_header Host $http_host;
  22. proxy_set_header X-Real-IP $remote_addr;
  23. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  24. }
  25. }