-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
sqs: add ability to define the external port #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -60,7 +60,7 @@ def return_response(self, method, path, data, headers, response, request_handler | |||
# return https://... if we're supposed to use SSL | |||
content_str = re.sub(r'<QueueUrl>\s*http://', r'<QueueUrl>https://', content_str) | |||
# expose external hostname:port | |||
external_port = get_external_port(headers, request_handler) | |||
external_port = SQS_PORT_EXTERNAL if SQS_PORT_EXTERNAL else get_external_port(headers, request_handler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: could be simplified to
external_port = SQS_PORT_EXTERNAL or get_external_port(headers, request_handler)
@@ -5,7 +5,7 @@ | |||
from six.moves.urllib.parse import urlencode | |||
from requests.models import Request, Response | |||
from localstack import config | |||
from localstack.config import HOSTNAME_EXTERNAL | |||
from localstack.config import HOSTNAME_EXTERNAL, SQS_PORT_EXTERNAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot import SQS_PORT_EXTERNAL
here as it hasn't been exposed as a variable in config.py
. This currently results in a failed build.
There are two options here:
- Remove the import, and retrieve the value in line 63 via
int(os.environ.get('SQS_PORT_EXTERNAL') or 0)
- Expose the
<SERVICE>_PORT_EXTERNAL
variables inconfig.py
, similar toPORT_<SERVICE>
Thanks for this PR @nemtsov - I added a comment related to the failed build. |
@nemtsov looks like you are almost there. It may be worth to rebase this or on master and implemented the couple of suggestions :) |
@nemtsov Any updates on this PR? Would be great if we could get this feature merged. Thanks |
Closing in favor of #1047 |
First, thanks for your amazing work on
localstack
!Please treat this as a start of a conversation rather than a full-featured PR. I'm not certain that this is the right direction and would love your feedback.
Motivation
The issue I'm having is that I'm running
localstack
behind a proxy, which is running on a specific host (which is covered byHOSTNAME_EXTERNAL
, but is also on a different port from that of the proxy. So, when SQS returns the queue URL it returns theHOSTNAME_EXTERNAL
that I set, but returns the local port and not the port that the client requests the proxy with.[proxy:80]
->[localstack:4576]
->[elasticmq:4561]
What I've done at the moment, is I've set my SQS port to
:80
(which is what my proxy wants). This works, but in my opinion is more of a workaround because any other service needs to return a URL pointing back to itself, I will not be able to also put it on:80
as it will be taken by SQS.Proposed solution
So, the solution I'm proposing is to define a
<SERVICE>_PORT_EXTERNAL
and use that along withHOSTNAME_EXTERNAL
. Alternatively (and if there are no plans to useHOSTNAME_EXTERNAL
as a single external hostname for all services) we can change it to something like<SERVICE>_EXTERNAL_URI
, which would be ahost:port
combination specific to a service.