How to start my app in http and https ports?


Daniel Mikusa
 

Your app needs to listen on the port assigned to it. It can find this
information by looking at the environment variable named `PORT` and reading
the value out of that (it will be the port number). If your app is being
run by Diego, which is pretty much all CF installations now, the port
number will be 8080. You can get by with just manually configuring the
port to 8080, but technically you should read the port number from the PORT
environment variable as it could potentially change in the future.

Hope that helps!

On Thu, Sep 14, 2017 at 4:30 AM, Ushani Balasooriya <ushanib(a)gmail.com>
wrote:

Hi Daniel,
I have changed my app to be started on http transport and it is started on
port 9763 by default when I deploy it. So should this port be changed to
listen to 8080 when I deploy on PCF or anything else should be done? What
is the port assigned to $PORT variable if I use it in my application
runtime?


Ushani Balasooriya
 

Hi Daniel,
I have changed my app to be started on http transport and it is started on port 9763 by default when I deploy it. So should this port be changed to listen to 8080 when I deploy on PCF or anything else should be done? What is the port assigned to $PORT variable if I use it in my application runtime?


Ushani Balasooriya
 

Thanks Daniel


Daniel Mikusa
 

Your app doesn't need to start both. It should generally just listen on
port 8080 (but technically should be the port listed in the env variable
$PORT) for HTTP requests. HTTPS/TLS is handled at the platform layer.
Usually, there would be a load balancer in front of your CF installation
which accepts HTTPS/TLS requests and terminates them. It would then proxy
requests to the GoRouter & ultimately your application via HTTP.

There are some variations on this as you can have your LB send requests via
HTTPS to the GoRouter which is capable of terminating HTTPS/TLS too (if
it's configured as such). In this way, you can make sure encryption is in
use for one additional hop of the request. For small environments that
don't have LB's, it's also possible to have GoRouter handle incoming
requests directly and terminate HTTPS/TLS. This only works for small envs
though, because it limits you to having one GoRouter. I don't know how
this is handled in PCFDev, but I suspect it might be done this way.

If you require HTTPS/TLS all the way to your application, the current
solution is to use TCP routing instead of a web application. TCP routing
has a different request path which results in your application receiving
the TCP connection from the client. This allows you to configure HTTPS/TLS
at the application level and have traffic encrypted all the way to the app.

Hope that helps!

Dan

On Tue, Sep 12, 2017 at 8:55 AM, Ushani Balasooriya <ushanib(a)gmail.com>
wrote:

My app should start in https:9443 ports. How can I achieve this?

This should be my login url : https://localhost:9443/carbon/

If I use Diego container, should it always be port 8080? Please point me
to a proper document where I can deploy my image in PCF to start on https
port?

This is my log:

2017-09-12T18:14:55.382+05:30 [API/0] [OUT] Created app with guid
fd8a0ddd-06ba-441a-94c7-73a0099589ad
2017-09-12T18:14:57.446+05:30 [API/0] [OUT] Updated app with guid
fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"route"=>"7d708d12-35fa-4fc2-9a87-3d4f8e8fac17",
:verb=>"add", :relation=>"routes", :related_guid=>"7d708d12-35fa-
4fc2-9a87-3d4f8e8fac17"})
2017-09-12T18:15:01.708+05:30 [API/0] [OUT] Updated app with guid
fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"state"=>"STARTED"})
2017-09-12T18:15:01.723+05:30 [STG/0] [OUT] Creating container
2017-09-12T18:15:01.928+05:30 [STG/0] [OUT] Staging...
2017-09-12T18:15:01.928+05:30 [STG/0] [OUT] Successfully created container
2017-09-12T18:15:01.986+05:30 [STG/0] [OUT] Staging process started ...
2017-09-12T18:15:06.062+05:30 [STG/0] [OUT] Staging process finished
2017-09-12T18:15:06.066+05:30 [STG/0] [OUT] Exit status 0
2017-09-12T18:15:06.066+05:30 [STG/0] [OUT] Staging Complete
2017-09-12T18:15:06.095+05:30 [STG/0] [OUT] Destroying container
2017-09-12T18:15:06.260+05:30 [CELL/0] [OUT] Creating container
2017-09-12T18:15:06.378+05:30 [STG/0] [OUT] Successfully destroyed
container
2017-09-12T18:15:20.061+05:30 [API/0] [OUT] Updated app with guid
fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"memory"=>2048,
"disk_quota"=>1024})
2017-09-12T18:15:20.157+05:30 [API/0] [OUT] Updated app with guid
fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"state"=>"STOPPED"})
2017-09-12T18:15:20.382+05:30 [API/0] [OUT] Updated app with guid
fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"state"=>"STARTED"})
2017-09-12T18:15:20.391+05:30 [CELL/0] [OUT] Creating container


=======

{
"staging_env_json": {},
"running_env_json": {},
"environment_json": "invalid_key",
"system_env_json": {
"VCAP_SERVICES": {}
},
"application_env_json": {
"VCAP_APPLICATION": {
"cf_api": "http://api.local.pcfdev.io",
"limits": {
"fds": 16384,
"mem": 2048,
"disk": 1024
},
"application_name": "is5.3.0",
"application_uris": [
"is530.local.pcfdev.io"
],
"name": "is5.3.0",
"space_name": "pcfdev-space",
"space_id": "a725ead6-283c-481d-b727-251865593e67",
"uris": [
"is530.local.pcfdev.io"
],
"users": null,
"application_id": "fd8a0ddd-06ba-441a-94c7-73a0099589ad",
"version": "d4a02bd7-e358-490a-9498-1c359882e5cd",
"application_version": "d4a02bd7-e358-490a-9498-1c359882e5cd"
}
}
}


Ushani Balasooriya
 

My app should start in https:9443 ports. How can I achieve this?

This should be my login url : https://localhost:9443/carbon/

If I use Diego container, should it always be port 8080? Please point me to a proper document where I can deploy my image in PCF to start on https port?

This is my log:

2017-09-12T18:14:55.382+05:30 [API/0] [OUT] Created app with guid fd8a0ddd-06ba-441a-94c7-73a0099589ad
2017-09-12T18:14:57.446+05:30 [API/0] [OUT] Updated app with guid fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"route"=>"7d708d12-35fa-4fc2-9a87-3d4f8e8fac17", :verb=>"add", :relation=>"routes", :related_guid=>"7d708d12-35fa-4fc2-9a87-3d4f8e8fac17"})
2017-09-12T18:15:01.708+05:30 [API/0] [OUT] Updated app with guid fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"state"=>"STARTED"})
2017-09-12T18:15:01.723+05:30 [STG/0] [OUT] Creating container
2017-09-12T18:15:01.928+05:30 [STG/0] [OUT] Staging...
2017-09-12T18:15:01.928+05:30 [STG/0] [OUT] Successfully created container
2017-09-12T18:15:01.986+05:30 [STG/0] [OUT] Staging process started ...
2017-09-12T18:15:06.062+05:30 [STG/0] [OUT] Staging process finished
2017-09-12T18:15:06.066+05:30 [STG/0] [OUT] Exit status 0
2017-09-12T18:15:06.066+05:30 [STG/0] [OUT] Staging Complete
2017-09-12T18:15:06.095+05:30 [STG/0] [OUT] Destroying container
2017-09-12T18:15:06.260+05:30 [CELL/0] [OUT] Creating container
2017-09-12T18:15:06.378+05:30 [STG/0] [OUT] Successfully destroyed container
2017-09-12T18:15:20.061+05:30 [API/0] [OUT] Updated app with guid fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"memory"=>2048, "disk_quota"=>1024})
2017-09-12T18:15:20.157+05:30 [API/0] [OUT] Updated app with guid fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"state"=>"STOPPED"})
2017-09-12T18:15:20.382+05:30 [API/0] [OUT] Updated app with guid fd8a0ddd-06ba-441a-94c7-73a0099589ad ({"state"=>"STARTED"})
2017-09-12T18:15:20.391+05:30 [CELL/0] [OUT] Creating container


=======

{
"staging_env_json": {},
"running_env_json": {},
"environment_json": "invalid_key",
"system_env_json": {
"VCAP_SERVICES": {}
},
"application_env_json": {
"VCAP_APPLICATION": {
"cf_api": "http://api.local.pcfdev.io",
"limits": {
"fds": 16384,
"mem": 2048,
"disk": 1024
},
"application_name": "is5.3.0",
"application_uris": [
"is530.local.pcfdev.io"
],
"name": "is5.3.0",
"space_name": "pcfdev-space",
"space_id": "a725ead6-283c-481d-b727-251865593e67",
"uris": [
"is530.local.pcfdev.io"
],
"users": null,
"application_id": "fd8a0ddd-06ba-441a-94c7-73a0099589ad",
"version": "d4a02bd7-e358-490a-9498-1c359882e5cd",
"application_version": "d4a02bd7-e358-490a-9498-1c359882e5cd"
}
}
}