我有一个使用 django 构建的应用程序,angular 并使用 cloudfoundry 托管。 带有 http 的部分 URL 无法继续,例如 http://www.example.com/home 将失败,但 https://www.example.com/home 工作正常。
同样的方式 http://www.example.com 将重定向到 https://www.example.com 但是当给出半个URL时,重定向失败。
所以我对这个问题做了一些研究,发现nginx.conf文件需要编辑,找不到更多。 是否需要与 Django 应用程序一起上传到 Cloud Foundry
任何关于此的指南都将非常有帮助 CF 推送输出:
C:***dcms-api>cf push -b https://github.com/cloudfoundry/nginx-buildpack.git
Pushing from manifest to org DCMS / space Development as ***@***.com...
Using manifest file C:***dcms-apimanifest.yml
Getting app info...
Updating app with these attributes...
name: dcms
path: C:***dcms-api
buildpacks:
https://github.com/cloudfoundry/nginx-buildpack.git
disk quota: 512M
health check type: port
instances: 1
memory: 256M
stack: cflinuxfs3
env:
ACCEPT_EULA
DB_HOST
DB_NAME
DB_PORT
DB_USER
DB_USER_PASSWORD
SYS_NAME
SYS_PASSWORD
routes:
dcms***.com
Updating app dcms...
Mapping routes...
Comparing local files to remote cache...
Packaging files to upload...
Uploading files...
385.10 KiB / 385.10 KiB [=====================================================================] 100.00% 1s
Waiting for API to complete processing files...
Staging app and tracing logs...
Cell 9c6ffac8- creating container for instance eb1fe223-
Cell 9c6ffac8- successfully created container for instance eb1fe223-
Downloading app package...
Downloading build artifacts cache...
Downloaded app package (2M)
Downloaded build artifacts cache (108M)
-----> Download go 1.12.4
-----> Running go build supply
/tmp/buildpackdownloads/adf6125a52c1a65c9523985b5a87ec38 ~
-----> Nginx Buildpack version 1.1.9
-----> Supplying nginx
-----> No nginx version specified - using mainline => 1.17.10
-----> Installing nginx 1.17.10
Download
[https://buildpacks.cloudfoundry.org/dependencies/nginx/nginx_1.17.10_linux_x64_cflinuxfs3_2fe87dae.tgz]
**WARNING** nginx 1.17.x will no longer be available in new buildpacks released after 2020-05-01.
See: https://nginx.org/
**ERROR** nginx.conf file must be configured to respect the value of `{{port}}`
**ERROR** Could not validate nginx.conf: no {{port}} in nginx.conf
Failed to compile droplet: Failed to run all supply scripts: exit status 14
Exit status 223
Cell 9c6ffac8- stopping instance eb1fe223-
Cell 9c6ffac8- destroying container for instance eb1fe223-
Cell 9c6ffac8- successfully destroyed container for instance eb1fe223-
Error staging application: App staging failed in the buildpack compile phase
FAILED
我不确定在哪里放置以下nginx.conf?
nginx.conf:
worker_processes 1;
daemon off;
events { worker_connections 1024; }
http {
log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent';
default_type application/octet-stream;
include mime.types;
sendfile on;
gzip on;
tcp_nopush on;
keepalive_timeout 30;
server {
listen 8080;
server_name apps1-bg-int.icloud.intel.com .apps1-bg-int.icloud.intel.com;
location / {
root /home/vcap/app/static/UI;
index index.html;
proxy_redirect off;
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 https;
}
}
}
尝试:
listen {{port}};
它对我有用。
https://docs.cloudfoundry.org/buildpacks/nginx/index.html#port