api.conf.tpl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name $HOST_API;
  5. return 301 https://$HOST_API${DOLAR}request_uri;
  6. }
  7. server {
  8. listen 443 ssl;
  9. listen [::]:443;
  10. server_name $HOST_API;
  11. ssl_certificate /etc/nginx/certs/fullchain.pem;
  12. ssl_certificate_key /etc/nginx/certs/privkey.pem;
  13. root /opt/api/web;
  14. location /bundles/ {
  15. root /opt/api/web;
  16. }
  17. location / {
  18. try_files ${DOLAR}uri /index.php${DOLAR}is_args${DOLAR}args;
  19. }
  20. # DEV
  21. location ~ ^/(index_dev)\.php(/|$) {
  22. fastcgi_pass unix:/tmp/api/api.sock;
  23. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  24. include fastcgi_params;
  25. fastcgi_param SCRIPT_FILENAME ${DOLAR}realpath_root${DOLAR}fastcgi_script_name;
  26. fastcgi_param DOCUMENT_ROOT ${DOLAR}realpath_root;
  27. fastcgi_ignore_client_abort on;
  28. fastcgi_param REMOTE_ADDR ${DOLAR}http_x_real_ip;
  29. }
  30. # PROD
  31. location ~ ^/index\.php(/|$) {
  32. fastcgi_pass unix:/tmp/api/api.sock;
  33. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  34. include fastcgi_params;
  35. fastcgi_param SCRIPT_FILENAME ${DOLAR}realpath_root${DOLAR}fastcgi_script_name;
  36. fastcgi_param DOCUMENT_ROOT ${DOLAR}realpath_root;
  37. fastcgi_ignore_client_abort on;
  38. fastcgi_param REMOTE_ADDR ${DOLAR}http_x_real_ip;
  39. internal;
  40. }
  41. location ~ \.php$ {
  42. return 404;
  43. }
  44. }