我想通过地址为mydomain.com/dashboard_v2
的nginxproxy_pass
提供从adaptor-node生成的sveltekit构建版本svelte.config.js
是
import adapter from '@sveltejs/adapter-node';
import preprocess from "svelte-preprocess";
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
csrf: { checkOrigin: false },
paths: {base: '/dashboard_v2'}
},
};
export default config;
我正在使用npm run build
进行构建
我正在使用npm run preview -- --host
运行/etc/nginx/sites-enabled/mydomain.com
是
server {
listen 80;
listen [::]:80;
server_name mydomain.com;
root /home/ubuntu/website;
index index.html;
location / {
try_files $uri $uri/ =404;
}
location /dashboard_v2/ {
proxy_pass http://localhost:4173/dashboard_v2;
proxy_set_header Host $http_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;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.trimpixel.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.trimpixel.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
此配置产生too many redirect
错误。
此版本在location /
下运行良好,但在location /dashboard_v2
下无法运行
要使location /dashboard_v2
工作,需要做哪些更改?
1条答案
按热度按时间ojsjcaue1#
你好,我所知道的https的代码,需要在一个单独的服务器块。
然后从侦听端口80的服务器重定向到443
您可以查看this repo以获得完整的示例