Amazon Beanstalk - nginx configuration - nginx

I have recently deployed a Beanstalk application on EC2.
This application is deployed using Docker.
I have discovered that every Beanstalk EC2 machine comes with a nginx that acts as a proxy(I don't really understand why, not documented anywhere).
Now the problem is that I do not know which nginx should have its configuration optimized (worker_processes, worker_connections, etc.)
Now, I know what I do not want and that is to configure nginx in two places.
I also tried using passenger as standalone but passenger as standalone looks like nginx.
How do you manage this situation in production ?
why is there a default nginx running on the AWS EC2 AMI in the first place ?
you really configure two nginx ?
is first nginx just a proxy(on the AWS EC2 machine) ?
should not touch anything regarding topmost nginx ?
isn't this first nginx also affected by concurrency and should be optimized ?

Related

Running Next.js in production on HTTPS

I cannot figure out how to set my next js project to run on HTTPS.
I am using Next 12.3 and deploying on AWS EC2. I have my SSL sertificates and all ports are open. What should I do to run it like that?
P.S.
All the answers that I've found are about running on HTTPS during the development.
Some people even claimed that it is not natively supported by Next. Is this true?
If you setup nginx, this becomes extremely easy.
You can handle the SSL part in nginx and run your NextJS server normally and you will have a server running on HTTPS.
See Configuring HTTPS servers for setting up Nginx.

Apollo Server on Ubuntu 18.04 EC2 instance with HTTPS

i'm trying to deploy my simple apollo-server on an Ubuntu 18.04 instance from Amazon Web Services(AWS) EC2. It works fine, but i need/want the traffic to be over HTTPS instead. I was wondering which could be the best option. Im running the code with "forever"("forever start lib/index.js"), also using yarn (to start the project "yarn start"). I'm able to access the server with the ip address () and everything works fine. I would like to do it ASAP, already tried with apollo-server-lambda and others Nodejs hosting websites.
The easier way to do this on AWS is by using a EC2 load balancer. You just need to create an application load balancer and add your instance to the target group. Once you have the load balancer created, you can apply the SSL certificate easily on your load balancer. This approach doesn't require you to change your application code at all.
Please refer this docs.
https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-application-load-balancer.html
If you don't want to use a load balancer, you need to apply the SSL certificate on the application level. Hope this helps.

Multi-host deployment of ASP.NET Core applications

I am quite confused as I haven't seen any blogs or instructions on how to host ASP.NET Core/.NET Core applications with HA and multi-host deployments. All examples are either:
1) One NGINX reverse-proxy, one Kestrel
2) One IIS reverse-proxy, one Kestrel
And both components on same host. In real-life production environments, you have LB maybe service discovery, multiple frontends, multiple backends, etc. But for this case there are no instructions whatsoever. So my questions would be for multi-host environments:
Do I deploy one IIS/NGINX as LB/Reverse-proxy, and redirect requests to Kestrels running on many separate VM:s, i.e. various different IP:s?
Or do I run an NGINX/F5 for load-balancing on one host, then route http traffic to various VM:s that run IIS+Kestrel, or just Kestrel? Is IIS required in this setup as NGINX acts as LB?
If I run IIS or NGINX as reverse-proxy, can they keep alive Kestrels on different VM:s, or does each Kestrel require exactly one IIS/NGINX to keep it alive? I.e. the Kestrel process must be on the same same host as the reverse-proxy?
All answers are very welcome, and thanks a lot in advance! :)
I'm running NGINX at the edge as a load balancer and for SSL Termination and multiple servers with IIS + Kestrel serving MVC. This is working well for us. You may not need it but I've found NGINX to be quite a bit more sophisticated and powerful than anything you could do with IIS. Obviously F5 or something would work as well. Previously I also ran for a while using AWS ELB load balancers which also worked fine, just didn't have much configurability. So depends on your needs.
As was mentioned already, IIS is needed on each box running kestrel to manage the process. You could do this some other way, but using IIS is the easiest.
I have a setup with one VM using (IIS as LB) + several VMs with (IIS + Kestrel). It's working fine for my usage, but I'm curious to see if other people have different suggestions. Then it depends on what you are doing, if you use encryption, machine key needs to be shared between VMs, you might also needs to share session between VMs (https://www.exceptionnotfound.net/finding-and-using-asp-net-session-in-core-1-0/), store things in database ...

How do I get my dreamweaver site to use my nginx docker container as a web test server?

I'm new to using docker though I followed the tutorials to create a nginx web server container and I have a website created in Dreamweaver. I was wanting to know how I can use the virtual web server to host my Dreamweaver site as a test server. Can I just open the kitematic and grab a nginx and place my Dreamweaver file into like the 2048 (game) example on there website?
This question is pretty broad but in essence you'd want to start with the nginx docker image. Create a Dockerfile that copies and configures your dreamweaver app and use the FROM nginx directive.
More info here
I think that using a FROM nginx is a bad idea. NGINX is a service on its own and should run within a docker as a stand-alone.
Your website-docker and your nginx-docker should communicate together using --link <name or id>:alias.
If you have several websites, you should have several dockers but still only one nginx. So if every websites docker embedded their own nginx that's messy and far away from the best practice...

Why use uWSGI and supervisor with a Flask app, and not just supervisor?

I usually run my Flask applications with uWSGI and an nginx in front of it.
But I was thinking that the same could be achieved with just supervisor and nginx, so I googled around and found a lot of posts on how to setup and the benefits of the uWSGI-supervisor-nginx stack. I've decided to turn to SO, risking getting axed online for such a question.
So what are the benefits of running a Flask application behind uWSGI, supervisor and nginx?
Why does apparently no one run Flask applications with only supervisor?
An app server such as gnicorn or uWSGI (used to host the flask applications) is used with nginx. nginx is a reverse proxy server which acts as a middleman. This helps with load balancing - handling multiples requests efficiently by distributing workloads over the resources. On top of this, supervisor is just used to monitor and control the server processes (gunicorn or uWSGI in our example).
From my understanding, the web server that comes with Flask (werkzeug server) is not production ready and should be used for development purposes only.
It's all about performance. Usually servers build into frameworks like Flask or Django are design for development environment, when you can quickly and easily reload code which you changed.
When you are running your application in production environment you don't have to worry about debugging and reloading your code often. Your biggest concerns are performance, security and configuration. During setting up production environment you can choose between uWSGI, Gunicorn , mod_wsgi and many others.
You can find plenty of blog posts with benchmarks between them and choose one which works best for you.

Resources