Skip to content
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

SENTRY_ALLOW_ORIGIN does not work since nginx and relay #494

Closed
guillkara opened this issue May 15, 2020 · 7 comments
Closed

SENTRY_ALLOW_ORIGIN does not work since nginx and relay #494

guillkara opened this issue May 15, 2020 · 7 comments
Assignees

Comments

@guillkara
Copy link

guillkara commented May 15, 2020

Hi,

I m using Sentry fro Angular projects.

I tried to update Sentry but since the containers relay and nginx have been added (#421) the property
SENTRY_ALLOW_ORIGIN does not send header as wanted.

As a workaround, I ve added again the ports on web :
web:
<< : *sentry_defaults
ports:
- '9000:9000/tcp'

and remove it on nginx
nginx:
ports:
- '9000:80/tcp'

How can we do to make the SENTRY_ALLOW_ORIGIN work with the default configuration ?

Regards

Guillaume Pierron

@BYK
Copy link
Collaborator

BYK commented May 18, 2020

I think this issue should be resolved by #463. Can you check if you have that fix in your local and if not, try with that applied?

@guillkara
Copy link
Author

Hi,

Thanks for your reply.

Yes I have included this commit.
I m up to date.

Regards,

@BYK
Copy link
Collaborator

BYK commented May 19, 2020

I couldn't find any reason why this would break with Nginx suddenly. Can you share some request logs from Nginx and Sentry Web so we can diagnose?

@guillkara
Copy link
Author

guillkara commented May 19, 2020

Hi,

This is my docker-compose configuration :
web:
ports:

  • '80:9000/tcp'
    nginx:
    ports:
  • '9000:80/tcp'

These are the requests :

WEB
Request URL: http://localhost/api/2/store/?sentry_key=1ab96bfb9cbb478f8b836f2bcde60894&sentry_version=7
Request Method: POST
Status Code: 200 OK
Remote Address: [::1]:80
Referrer Policy: origin

REQUEST HEADERS
POST /api/2/store/?sentry_key=1ab96bfb9cbb478f8b836f2bcde60894&sentry_version=7 HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 12363
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: /
Origin: http://localhost:4200
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: fr-FR,fr;q=0.9,es;q=0.8,en-US;q=0.7,en;q=0.6,nl;q=0.5

RESPONSE HEADERS
HTTP/1.1 200 OK
Content-Length: 41
Access-Control-Allow-Headers: X-Sentry-Auth, X-Requested-With, Origin, Accept, Content-Type, Authentication, Authorization, Content-Encoding
X-Content-Type-Options: nosniff
Content-Language: fr
Access-Control-Expose-Headers: X-Sentry-Error, Retry-After
Expires: Tue, 19 May 2020 08:59:23 GMT
Vary: Accept-Language, Cookie
X-XSS-Protection: 1; mode=block
Allow: GET, POST, HEAD, OPTIONS
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Access-Control-Allow-Origin: http://localhost:4200
Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS
Content-Type: application/json
X-Frame-Options: deny

NGINX
Request URL: http://localhost:9000/api/2/store/?sentry_key=1ab96bfb9cbb478f8b836f2bcde60894&sentry_version=7
Referrer Policy: origin

HTTP/1.1 502 Bad Gateway
Server: nginx/1.16.1
Date: Tue, 19 May 2020 09:01:45 GMT
Content-Type: text/html
Content-Length: 559
Connection: keep-alive

POST /api/2/store/?sentry_key=1ab96bfb9cbb478f8b836f2bcde60894&sentry_version=7 HTTP/1.1
Host: localhost:9000
Connection: keep-alive
Content-Length: 12363
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: /
Origin: http://localhost:4200
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: fr-FR,fr;q=0.9,es;q=0.8,en-US;q=0.7,en;q=0.6,nl;q=0.5

In my console, this is what I have
Access to fetch at 'http://localhost:9000/api/2/store/?sentry_key=1ab96bfb9cbb478f8b836f2bcde60894&sentry_version=7' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

i can connect to the interface on both port 80 or 9000.

Hope this could help,

Thanks

@guillkara
Copy link
Author

I found my issue.
The relay couldn't start because fiel credentials.json was not writable.

Sorry for your time.

Thanks,

@llisonly
Copy link

llisonly commented Sep 9, 2020

@guillkara how to config, i have the same issue

@BYK
Copy link
Collaborator

BYK commented Sep 9, 2020

@llisonly please see the previous comment: #494 (comment) and follow our guideline for asking for help: https://develop.sentry.dev/self-hosted/support/

@getsentry getsentry locked as resolved and limited conversation to collaborators Sep 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants