我有一个用于前端的nuxt应用程序SPA和一个laravel API。Nuxt调用API请求。我试图将它部署在一个数字海洋水滴中,但我遇到了问题。我的laravel应用程序似乎可以正常工作,但我无法让nuxt显示我的设置
Ubuntu 20 nginx 1.18 php 7.4
laravel nginx服务器块
server {
listen 80;
server_name DROPLET_IP;
root /var/www/laravel-api/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}}
这是我的nuxt服务器块:
server {
listen 3000;
server_name DROPLET_IP;
keepalive_timeout 60;
index index.html;
location / {
root /var/www/nuxt-front/dist;
}
}这两个都在他们自己的站点中-可用并启用指向站点的符号链接。
由于某些原因,当我访问http://DROPLET_IP:3000时。它就挂起来了。
有没有一种特殊的方式可以让我按预期运行呢?
发布于 2021-02-22 18:43:49
使用root
server {
listen 80;
server_name example.com;
keepalive_timeout 60;
root /var/www/nuxt-front/dist;
}或
使用代理传递
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}https://stackoverflow.com/questions/65369328
复制相似问题