gpt4 book ai didi

javascript - Meteor 应用程序用 mup 延迟,在 nginx 后面不显示

转载 作者:行者123 更新时间:2023-12-03 10:02:25 26 4
gpt4 key购买 nike

我正在尝试将一个应用程序部署到我自己的服务器上,并使用 mup 在 nginx 后面工作,以便我可以通过路由将端口 80 定向为该应用程序(在默认页面上运行的其他内容)。

该应用程序在 http://hostname:3080 上运行良好但是当我尝试 http://hostname/dashboard我得到一个空白页。奇怪的是,两种情况下的页面源完全相同,并且看起来应该加载页面。

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" class="__meteor-css__" href="/8794b5f3e7ececaa1db27feee7ff3db2d00e9dcb.css?meteor_css_resource=true">


<script type="text/javascript">__meteor_runtime_config__ = JSON.parse(decodeURIComponent("%7B%22meteorRelease%22%3A%22METEOR%401.1.0.2%22%2C%22PUBLIC_SETTINGS%22%3A%7B%7D%2C%22ROOT_URL%22%3A%22http%3A%2F%2Fhostname%22%2C%22ROOT_URL_PATH_PREFIX%22%3A%22%22%2C%22accountsConfigCalled%22%3Atrue%2C%22autoupdateVersion%22%3A%224455357f08556a49e92dd81d31c4c19d9a2204f6%22%2C%22autoupdateVersionRefreshable%22%3A%22caae7981cd6ec189870ba445ac392be58af0b0ab%22%2C%22autoupdateVersionCordova%22%3A%22none%22%7D"));</script>

<script type="text/javascript" src="/c97b1ea7dc444b12e68fdb14f80afc8a0374c861.js"></script>




</head>
<body>

</body>
</html>

我的 nginx 配置如下(我目前只测试 http 部分,但 https 位返回了自签名证书,并且再次具有相同的页面源。

server_tokens off; # for security-by-obscurity: stop displaying nginx version

# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

upstream dashboard {
server 127.0.0.1:3080;
}

# HTTP
server {
listen 80 default_server; # if this is not a default server, remove "default_server"
listen [::]:80 default_server;

root /usr/share/nginx/html; # root is irrelevant
index index.php index.html index.htm; # this is also irrelevant

server_name hostname; # the domain on which we want to host the application. Since we set "default_server" previously, nginx will answer all hosts anyway.
access_log /var/log/nginx/dashboard.access;
# redirect non-SSL to SSL
location /dashboard/ {
#proxy_pass http://127.0.0.1:3080;
#proxy_pass http://hostname:3080;
proxy_pass http://dashboard/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forward-For $remote_addr;
proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forward-Proto http;
#proxy_set_header X-Nginx-Proxy true;

#proxy_redirect off;

#rewrite ^ https://$server_name$request_uri? permanent;
}
}

# HTTPS server
server {
listen 443 ssl spdy; # we enable SPDY here
server_name hostname; # this domain must match Common Name (CN) in the SSL certificate

#root html; # irrelevant
#index index.html; # irrelevant

ssl_certificate /etc/nginx/ssl/dashboard.crt;
ssl_certificate_key /etc/nginx/ssl/dashboard.key;

# performance enhancement for SSL
ssl_stapling on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;

# safety enhancement to SSL: make sure we actually use a safe cipher
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK';

# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
add_header Strict-Transport-Security "max-age=31536000;";

# If your application is not compatible with IE <= 10, this will redirect visitors to a page advising a browser update
# This works because IE 11 does not present itself as MSIE anymore
if ($http_user_agent ~ "MSIE" ) {
return 303 https://browser-update.org/update.html;
}

# pass all requests to Meteor
location /dashboard/ {
proxy_pass http://127.0.0.1:3080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; # allow websockets
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr; # preserve client IP

# this setting allows the browser to cache the application in a way compatible with Meteor
# on every applicaiton update the name of CSS and JS file is different, so they can be cache infinitely (here: 30 days)
# the root path (/) MUST NOT be cached
if ($uri != '/') {
expires 30d;
}
}
}

其中主机名替换为我的实际主机名。

访问日志文件似乎显示代码正常,但其中有一些奇怪的 404,我不确定。

150.xxx.xxx.xx - - [29/May/2015:14:24:14 +1000] "GET /8794b5f3e7ececaa1db27feee7ff3db2d00e9dcb.css?meteor_css_resource=true HTTP/1.1" 404 136 "http://hostname/dashboard/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"
150.xxx.xxx.xx - - [29/May/2015:14:24:14 +1000] "GET /c97b1ea7dc444b12e68fdb14f80afc8a0374c861.js HTTP/1.1" 404 136 "http://hostname/dashboard/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"

有什么想法可以从这里开始吗?

最佳答案

如果您希望应用程序在 http://hostname/dashboard 上运行,您的 nginx 配置似乎是正确的,除了一件小事情之外。你应该做这样的事情。

# HTTP
server {
listen 80 default_server; # if this is not a default server, remove "default_server"
listen [::]:80 default_server;

root /usr/share/nginx/html; # root is irrelevant
index index.php index.html index.htm; # this is also irrelevant

server_name hostname; # the domain on which we want to host the application. Since we set "default_server" previously, nginx will answer all hosts anyway.
access_log /var/log/nginx/dashboard.access;
# redirect non-SSL to SSL
location /dashboard {
proxy_pass http://127.0.0.1:3080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
}

所以不需要upstream,还要确保运行时传递给meteor的ROOT_URL参数是http://hostname/dashboard端口是 3080,我相信这已经是这种情况了,因为你有 Meteor 应用程序在//hostname:3080

上工作

关于javascript - Meteor 应用程序用 mup 延迟,在 nginx 后面不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30521936/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com