I have an application built using django, angular and hosted using cloudfoundry. partial URL with http fails to proceed, for example http://www.example.com/home will fail but https://www.example.com/home will work fine.
same way http://www.example.com will redirect to https://www.example.com but when given with half URL the redirection is failing.
So i did some research on this issue, and found that nginx.conf file needs to be edited and could not find more. is it need to be uploaded with the django application to cloud foundry
any guide over this will be very helpful Out put of CF PUSH:
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-api\manifest.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
and i have a doubt on where to place the following 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;
}
}
}
cf pushfor your app. This will tell us more about what is deployed for your app. Generally for Python apps, you don't need/don't have Nginx. - Daniel Mikusa