Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. server {
  2. listen 80;
  3. server_name localhost;
  4.  
  5. index index.php index.html;
  6. root /app/public;
  7.  
  8. location / {
  9. try_files $uri /index.php$is_args$args;
  10.  
  11. # Simple requests
  12. if ($request_method ~* "(GET|POST)") {
  13. #add_header "Access-Control-Allow-Origin" * always;
  14. }
  15.  
  16. # Preflighted requests
  17. if ($request_method = OPTIONS ) {
  18. add_header "Access-Control-Allow-Origin" * always;
  19.  
  20. add_header "Access-Control-Allow-Methods" "GET, POST, PUT, OPTIONS, HEAD";
  21. add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
  22. return 200;
  23. }
  24. }
  25.  
  26. location ~ ^/index\.php(/|$) {
  27. try_files $uri =404;
  28.  
  29. # https://stackoverflow.com/questions/31493634/laravel-routes-not-found-on-nginx
  30. #try_files $uri $uri/ /index.php?$query_string;
  31.  
  32. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  33. fastcgi_pass laravel_vue_companies_php:9000;
  34. fastcgi_index index.php;
  35. include fastcgi_params;
  36. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  37. fastcgi_param PATH_INFO $fastcgi_path_info;
  38.  
  39. # Preflighted requests
  40. if ($request_method = OPTIONS ) {
  41. add_header 'Access-Control-Allow-Origin' '*';
  42. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  43.  
  44.  
  45. #
  46. # Custom headers and headers various browsers *should* be OK with but aren't
  47. #
  48. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  49. #
  50. # Tell client that this pre-flight info is valid for 20 days
  51. #
  52. add_header 'Access-Control-Max-Age' 1728000;
  53. add_header 'Content-Type' 'text/plain; charset=utf-8';
  54. add_header 'Content-Length' 0;
  55. return 204;
  56. }
  57.  
  58. if ($request_method = 'POST') {
  59.  
  60. # with this upload works, but does not work non upload post request
  61. # laravel handles GET so 2nd time header gives error on po
  62. #add_header 'Access-Control-Allow-Origin' '*' always;
  63.  
  64. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  65. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  66. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  67. }
  68. if ($request_method = 'GET') {
  69. # laravel handles GET so 2nd time header gives error
  70. #add_header 'Access-Control-Allow-Origin' '*' always;
  71. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  72. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  73. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  74. }
  75.  
  76.  
  77. }
  78.  
  79. location ~ \.php$ {
  80. return 404;
  81. }
  82.  
  83. error_log /var/log/nginx/error.log;
  84. access_log /var/log/nginx/access.log;
  85. }
  86.  
  87.  
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement