Comments (16)
I had a similar set up with webserver deployed on ECS behind an ALB with a cert. The static files were being served from http:// which caused issues when the rest of the webserver was using https://.
After updating the dockerfile command to
CMD ["uvicorn", "...", "--proxy-headers", "--forwarded-allow-ips", "*"]
It started working for me - note the lack of quotes around *
.
See referenced suggestion from a starlette thread: encode/starlette#538 (comment)
from sqladmin.
Thanks for your response @aminalaee, in fact we did get this working using:
class CustomUvicornWorker(UvicornWorker):
CONFIG_KWARGS = {
"proxy_headers": True,
"forwarded_allow_ips": "*"
}
from sqladmin.
Just look at your own eyes - https://app.narravia.com/admin/
Thanks guys, it is working :)
Just:
CMD ["poetry", "run", "uvicorn", "rest_api.api:app", "--host", "0.0.0.0", "--port", "8000", "--reload", "--forwarded-allow-ips", "*", "--proxy-headers"]
from sqladmin.
TBH this is a very specific deployment issue, not sure how I can help with that.
But clearly the issue is not with SQLAdmin itself rather in Uvicorn and the AWS deployment. I think you might have better chances of opening a discussion there.
from sqladmin.
Having same issue: #721
My details: #721 (comment)
One deployment works, one doesn't. So far, looks like an issue with SQLAdmin itself. Docs app served from the same FastAPI server, knows that it's https and works properly.
I outputted the headers and sql admin app is getting the x-forwarded-proto=https
, it should know to use the https urls.
Please advise what might be the issue.
from sqladmin.
I've also had my project deployed on AWS ECS using Fargate with load balancer and I've managed to make it work with static files as well. All I did to make it work, I've change the execution command from
uvicorn main:app --reload --port 8000 --host 0.0.0.0
to
uvicorn main:app --reload --port 8000 --host 0.0.0.0 --forwarded-allow-ips='*' --proxy-headers
You need to have some other error in the configuration of your AWS infrastructure.
from sqladmin.
I tried adding --forwarded-allow-ips='*'
and --proxy-headers
and still same result.
Also tried this:
CMD ["gunicorn", "app.main:app", "--workers=4", "--worker-class=app.uvcorn_worker.CustomUvicornWorker", "--bind=0.0.0.0:8000", "--forwarded-allow-ips='*'", "--proxy-allow-from='*'", "--proxy-protocol"]
with the custom worker:
from uvicorn.workers import UvicornWorker
class CustomUvicornWorker(UvicornWorker):
CONFIG_KWARGS = {"proxy_headers": True}
All the same.
Curl on /admin
returns location as http.
Headers are passed to the admin app and indicate https.
from sqladmin.
How did you assign SSL certificates to your page. Maybe there is a problem ...
from sqladmin.
The SSL is created via ACM, validated via DNS. Browsers trust the license.
Is there any way to force https?
from sqladmin.
Contact me via form at https://www.mspacelock.com/contact if you wish we can do some troubleshooting via call or email and compare our configurations
from sqladmin.
Thanks for the offer. Still don't know what's the issue exactly. I bypassed it by setting up FastAPI app with ssl + updating the target group to use https for the traffic with the container.
from sqladmin.
@neara what would you think of a solution where you inject a middleware on the Admin class initialization and in the dispatch method to change the scheme from http to https inside the fastapi request.
request.scope["scheme"] = "https"
from sqladmin.
I'm having the same issue. I think that happens because the python project starts as HTTP, without a certificate, so the function url_for in base.html generates a url with http. The python project doesn't know that the ALB assigns a certificate.
Right now I can't try and test, but I came up with the following ideas:
-
Use custom templates, with the same login.html (and others templates) but a custom base.html
-
Manually overwrite the starlette route "admin:statics"
from sqladmin.
We're seeing this too, and it's blocking deploys to EBS/EC2 where we're using the Docker platform and running gunicorn with UvicornWorker similar to #720 (comment).
Anyone found a workaround?
from sqladmin.
@onejgordon Didn't what @vishalbollu mention work?
from sqladmin.
@Mowinski can you also confirm this has worked for you so we can close this?
from sqladmin.
Related Issues (20)
- CSS and Javascript files for the Admin not loaded HOT 2
- Overriden form text field with FileUpload field. HOT 7
- Not able to edit fields in sql admin when using s3 filetype HOT 3
- Unexpected main page view HOT 6
- Add ModelView.form_query property to create form-filtering feature HOT 2
- override delete model method to perform soft delete HOT 1
- form_overrides doesn't work HOT 2
- SqlAlchemy dataclass support missing HOT 6
- Multiple Admin Instances result in wrong URL's to the views HOT 1
- Ajax query passes incorrect urn when admin mounted on sub fastapi app HOT 3
- Sort symbol is incorrect (wrong direction)
- sqladmin + jinja templates conflict index.html HOT 3
- Raised value error HOT 5
- Define default values via form_args
- TypeError: UUID objects are immutable (fastapi_users) HOT 4
- ValueError on passing unexcepted parameter
- Use HTMX HOT 3
- jinja2.exceptions.TemplateNotFound: list.html HOT 3
- What about Router per View? HOT 2
- with ... as ... statement can make sesssion close,which will lead to DetachedInstanceError HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqladmin.