У меня работает приложение Vuejs + Laravel, использующее прокси NGINX.Все мои просьбы Laravel основаны на отдыхе и на www./app/$.Он работал нормально в отдельных портах.Но когда я перешел на SSL.Мой веб-интерфейс (Vuejs) все еще работает нормально, но всякий раз, когда я пытался отправить почтовый запрос на сервер (laravel), я получаю [error] 8 # 8: * 80 FastCGI, отправленный в stderr: «Основной сценарий неизвестен» при чтении заголовка ответа из апстрима.
В 443 блоке ssl я переадресовываю все остальные вызовы API в phpfpm, но он как-то не работает.Каков рекомендуемый способ развертывания этих vuejs + laravel в SSL nginx.
В прошлом я пытался переместить phpfpm в блок ssl-сервера.Я попытался добавить http в настройке fastcgi.После всех изменений, следующий код:
Ниже мой файл конфигурации.
server {
listen 81; # backend at laravel
index index.php index.html;
root /var/www/public;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
server {
listen 88; # frontend vuejs build app
index index.html;
server_name app.lookahead.com www.app.lookahead.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/front;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name app.lookahead.com;
ssl_certificate /etc/certs/app.lookahead.com/cert.crt;
ssl_certificate_key /etc/certs/app.lookahead.com/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8088;
proxy_read_timeout 90;
return 301 https://www.app.lookahead.com$request_uri;
}
location ^~ /api {
root /var/www/public; #backend api at this root
try_files $uri $uri/ /api/index.php$is_args$args;
location ~* \.php(/|$) {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
##https://www.app.lookahead.com
server {
server_name www.app.lookahead.com;
listen 443;
ssl_certificate /etc/certs/app.lookahead.com/cert.crt;
ssl_certificate_key /etc/certs/app.lookahead.com/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
root /var/www/front; #frontend static vuejs files at this root
index index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ^~ /api {
root /var/www/public; # backend api is at this root
try_files $uri $uri/ /api/index.php$is_args$args;
location ~* \.php(/|$) {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
# nginx serving frontend
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
}