nginx.conf 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. server {
  2. listen 9090;
  3. listen [::]:9090 ipv6only=on;
  4. set $cors '';
  5. if ($http_origin ~ '^https?\:\/\/(localhost|\d+\.\d+\.\d+.\d+|(www\.)?ispooge\.com|(www\.)?harlanji\.com|(www\.)?tinydatacenter\.com)\/?') {
  6. set $cors 'C';
  7. }
  8. set $cors_opts '';
  9. if ($request_method = 'OPTIONS') {
  10. set $cors_opts "${cors}O";
  11. }
  12. location / {
  13. if ($cors = 'C') {
  14. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  15. add_header 'Access-Control-Allow-Credentials' 'true' always;
  16. add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
  17. add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
  18. # required to be able to read Authorization header in frontend
  19. #add_header 'Access-Control-Expose-Headers' 'Authorization' always;
  20. }
  21. if ($cors_opts = 'CO') {
  22. add_header 'Access-Control-Max-Age' 60;
  23. add_header 'Content-Type' 'text/plain charset=UTF-8';
  24. add_header 'Content-Length' 0;
  25. return 204;
  26. }
  27. root /var/www/html;
  28. }
  29. }