question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

https support for target URL

See original GitHub issue

Following is my gateway configuration :

const gateway = require(‘fast-gateway’)
server = gateway(
{
routes: [
{
prefix: ‘/fakeservice’,
target: ‘https://reqres.in/’,    //--->target URL with **HTTPS**
docs: {
name: ‘Fake service’,
endpoint: ‘/api/users/2’,
},
},
{
prefix: ‘/empservice’,
target: ‘http://dummy.restapiexample.com/’,   //--->target url with **HTTP**
docs: {
name: ‘Employee Service’,
endpoint: ‘/api/v1/employees’,
}
},
]
}
);
server.start(3123);

While I am running locally using following URLs to route, I have success and failure :

  1. http://localhost:3123/fakeservice/api/users/2 —> FAILED : Returning NOT found error, even though target https://reqres.in/api/users/2 returns valid JSON

  2. http://localhost:3123/empservice/api/v1/employees —> SUCCEEDED : Returning success response with JSON payload as expected.

Question: does fast-gateway support target with HTTPS? If so, then why it’s not working? Am I missing any configuration? Do I need to add any extra parameter to route target having HTTPS protocol?

Please help. I am planning to use this in commercial production delivery project.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:15

github_iconTop GitHub Comments

1reaction
jkyberneeescommented, Apr 9, 2020

Hi @skskcco2o17, v2.3.3 was released with the latest version of fast-proxy. Now you are able to modify the request headers, in this case, required for Cloudflare.

Here a working example:

const gateway = require('fast-proxy')

gateway({
  routes: [{
    prefix: '/httpbin',
    target: 'https://httpbin.org'
  }, {
    prefix: '/jsonplaceholder',
    target: 'https://jsonplaceholder.typicode.com',
    hooks: {
      rewriteRequestHeaders (req, headers) {
        delete headers['x-forwarded-host']

        return headers
      }
    }
  }]
}).start(8080)

Looking forward to your feedback, feel free to close this issue on success.

Regards, Rolando

0reactions
jkyberneeescommented, Apr 11, 2020

Hi @skskcco2o17, is great to hear that it worked for you. v2.3.4 of fast-gateway is out with the fix. So you don’t need delete headers.host anymore.

For using self-signed certs you can use:

const gateway = require('./../index')

gateway({
  routes: [{
    fastProxy: {
      rejectUnauthorized: false
    },
    prefix: '/httpbin',
    target: 'https://httpbin.org'
  }]
}).start(8080)

I am closing this issue, in case you have other issues, feel free to contact me again.

Best Regards, Rolando

Read more comments on GitHub >

github_iconTop Results From Across the Web

Help Home - Target
Browse all Help pages. Holiday Help. Holiday Help. Orders & Purchases. Print a receipt; Create order; Edit or cancel order; Track order; Order...
Read more >
https in default-target-url spring security - java - Stack Overflow
For reference, question is cross posted @ Code ranch PS: I can TargetUrlResolver help me in configurations ? java · https · spring-security....
Read more >
Create an HTTPS listener for your Application Load Balancer
To add an HTTPS listener using the console · Choose Add action, Forward to and choose a target group. · Choose Add action,...
Read more >
Configuring target URL mapping - 11.2 - Documentation
When you have more than one target session defined in an identity provider (IdP) connection, you must map the target URL to its...
Read more >
Notifying external targets - Zendesk help
Setting up a target ; URL, Pass URL parameters to any URL. You can use placeholders as values. Example: www.some-address.com?customer_name={{ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found