在Nginx的URI路径上服务symfony应用

时间:2018-07-19 14:58:11

标签: php symfony nginx homestead

这是我必须在app.test中使用此symfony应用程序的nginx配置。 我需要在app.test/path上进行投放,以遵守第三方服务。

要实现此目标我应该改变什么?

server {
   listen 80;
   listen 443 ssl http2;
   server_name app.test;
   root "/home/vagrant/code/app/web";

   index index.html index.htm index.php app_dev.php;

   charset utf-8;

   location / {
       try_files $uri $uri/ /app_dev.php?$query_string;
   }


   location = /favicon.ico { access_log off; log_not_found off; }
   location = /robots.txt  { access_log off; log_not_found off; }

   access_log off;
   error_log  /var/log/nginx/app.test-ssl-error.log error;

   sendfile off;

   client_max_body_size 100m;

   # DEV
   location ~ ^/(app_dev|app_test|config)\.php(/|$) {
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


       fastcgi_intercept_errors off;
       fastcgi_buffer_size 16k;
       fastcgi_buffers 4 16k;
   }

   # PROD
   location ~ ^/app\.php(/|$) {
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


       fastcgi_intercept_errors off;
       fastcgi_buffer_size 16k;
       fastcgi_buffers 4 16k;
       internal;
   }

   location ~ /\.ht {
       deny all;
   }

   ssl_certificate     /etc/nginx/ssl/app.test.crt;
   ssl_certificate_key /etc/nginx/ssl/app.test.key;
}

0 个答案:

没有答案