nginx.conf 875 B

123456789101112131415161718192021222324252627
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. charset utf-8;
  5. error_page 500 502 503 504 /50x.html;
  6. # 防止爬虫抓取
  7. if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot")
  8. {
  9. return 403;
  10. }
  11. location / {
  12. root /usr/share/nginx/html;
  13. try_files $uri /index.html;
  14. }
  15. location /api {
  16. proxy_set_header X-Real-IP $remote_addr; #转发用户IP
  17. proxy_pass http://app:3002;
  18. }
  19. proxy_set_header Host $host;
  20. proxy_set_header X-Real-IP $remote_addr;
  21. proxy_set_header REMOTE-HOST $remote_addr;
  22. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  23. }