react-scripts localhost http2 - reactjs

I have a CRA project running which in development mode (yarn start) is slow because of multiple requests being fired and many requests are stale for a long time. In production (deployed on an Apache server) this problem of stale requests holding back future requests is solved.
A difference I can spot is the localhost to api endpoint via a proxy configuration in package.json is running over HTTP/1 and the deployed variant runs over HTTP/2 which allow more requests to be handled simultaneously.
Does this theory of HTTP/1 over 2 makes any sense for my problem?
I can't find a way to allow my localhost to proxy over HTTP/2 to my remote server.

Related

502 Bad Gateway Nginx error while deploying Django Channels app using Daphne on Google App Engine (Flexible)

My Django app was working fine on Google App Engine (Flexible) using gunicorn as entrypoint in the app.yaml file. I needed to add websockets to it so I used Django Channels (with redis). This works beautifully on my local machine (Windows 10).
For deployment, I changed my entrypoint to daphne on port 8080 since that's the default on GAE (using $PORT produces the same effect), so my yaml file now looks like this:
runtime: python
env: flex
runtime_config:
python_version: 3
entrypoint: daphne -b 127.0.0.1 -p 8080 my_project_name.asgi:application
I've checked my .asgi file and requirements.txt to ensure everything is ok and the packages are the latest versions.
But after deploying it, I get a "502 Bad Gateway Nginx" error.
The Stackdriver logs (nginx.error) on the GCP cloud console say the below:
[error] 33#33: *341 connect() failed (111: Connection refused) while connecting
to upstream, client: 172.xxx.xxx.xxx, server: , request: "GET / HTTP/1.1",
upstream: "172.17.0.1:8080", host: "my_project_name.appspot.com"
I don't recognize those IPs for upstream server or client, and I don't know what to do next. I've tried numerous things over the last 4 days, including:
using various different ports (8000, 8001 etc)
adding an nginx.conf file (based on this documentation) in my project directory, which seems to make no difference
Adding a line in the runtime_config section of the yaml file that says "nginx_conf_http_include: nginx.conf"
4.Using Unix sockets to start the daphne server in the entrypoint like "entrypoint: daphne -u /tmp/daphne.sock my_project_name.asgi:application
Deleting the entrypoint altogether after declaring the daphne server in the nginx.conf file
None of this helps. The logs stay the same, the error stays the same. I've read SO questions like this and this but I don't know how to apply them to GAE Flex since I'm not directly operating the VM instance. Please help.

Daphne on Google App Engine Flexible for Django Channels app: 502 Bad Gateway Error nginx

I'm new to web development so I appreciate some hand-holding by the smart folks here. I'm trying to switch from gunicorn to Daphne for my Django app on GAE Flex, since I need to use Django Channels.
Previously the site worked fine with gunicorn as entrypoint (in the app.yaml file). I just replaced it with daphne (I'd like to avoid complexity by changing nginx configurations, Unix sockets etc so I guess I'm ok with Daphne serving both HTTP and ws requests). So now my app.yaml looks like:
runtime: python
env: flex
runtime_config:
python_version: 3
entrypoint: daphne -b 0.0.0.0 -p 8001 my_project_name.asgi:application
I've already made a .asgi file next to my .wsgi file and declared an application there.
In requirements.txt I've ensured the daphne(2.4.1) and asgiref(3.2.3) packages are the latest versions.
Finally when I do 'gcloud app deploy', deployment appears to happen smoothly and in the build logs I can see daphne starting:
Step #1: Step 9/9 : CMD exec daphne -b 0.0.0.0 -p 8001 my_project_name.asgi:application
Step #1: ---> Running in c6f3762a5ce2
But I'm getting a 502 Bad Gateway error on the site, with "nginx" in the next line.
Question: What am I doing wrong? Is this because Daphne is not serving http requests? Am I supposed to do anything different to make Daphne serve HTTP requests? Right now my http paths are served in Django by the urls.py module and not the routing.py module (which is taking care of only ws requests). Am I supposed to change that in some way?
If you feel that splitting incoming requests and sending http to gunicorn is the only way, please describe those steps. What happens to the entrypoint in the app.yaml file if I do that?
My efforts so far: I see many questions on SO (such as this and this) and other tutorials online on how to use daphne on standalone linux machines but not on app engines like GAE Flex. The only GAE-related post I saw was this, but it's a different problem from mine.

Connecting a secured websocket on Google Appengine frontend with managed VM with nodejs runtime

I've trouble in connecting to a wss secured socket server via google appengine frontend with managed VM support.
buy default google exposes only port 8080 in docker image google/nodejs-runtime, Even if expose port 8443 in Dockerfile like below i can connect only to http://localhost:8080 not https://localhost:8443
FROM google/nodejs
WORKDIR /app
ADD package.json /app/
RUN npm install
ADD . /app
EXPOSE 8443
CMD []
ENTRYPOINT ["/nodejs/bin/npm", "start"]
Still i can see port 8080 include in the container
"/nodejs/bin/npm start 8443/tcp, 0.0.0.0:8080->8080/tcp
If i log in to my managed vm instance and run the container image with
docker run -d -p 8443:8443 nodejs.default.wss-check:latest
and try
$curl https://localhost:8443
I get curl: (60) SSL certificate problem: unable to get local issuer certificate, It looks like its connecting but i've to use realdomain name
I've created a issue in github aswell https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart/issues/13, but not that helpful.
Same set up works like a charm in normal compute instance. but it doesn't auto scale.
Any help on this issue will be appreciated.
The reason you can't curl to https on localhost (curl: (60) SSL certificate problem: unable to get local issuer certificate) is because "localhost" is unknown to any CA. You need to run curl -k https://localhost:8443 to get it to ignore the lack of a certificate for localhost.
Looks like currently Google Managed VM supports Websocket connection only on JAVA
Even if you try websocket connection on with nodejs on GMV it defaults to polling transport. if you wanna see this in live you can use set socket transports, deploy to live and look in to console- network and see which transport its using!
socket.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
We have to wait untill google implements websocket support in Managed VM. If anyone get this working on GMV, Please comment here :)

App Engine Go SDK web server running in Vagrant guest (with port forwarding) not reachable from host

I'm running GAE dev server within a Vagrant guest precise64 box with the following network setup (in my Vagrantfile):
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network :forwarded_port, guest: 8080, host: 9090
end
Which does its thing:
[default] Forwarding ports...
[default] -- 8080 => 9090 (adapter 1)
I start my App Engine server with:
goapp serve
or
dev_appserver.py myappfolder
This starts app engine dev server as expected:
INFO 2013-11-22 dispatcher.py] Starting module running at: http://localhost:8080
In all cases, I'm able to ssh in to the Vagrant guest and curl localhost:8080 successfully.
Unfortunately, from the host I'm unable to get a response from localhost:9090 when running GAE dev web server. Additionally, I've made sure that I don't have anything interfering with the port 9090 on the host machine. Also, I'm almost positive this isn't related to Vagrant as I spun up a quick node.js web server on 8080 and was able to reach it from the host. What am I missing?!!!
You must run the Google App Engine Go dev web server on 0.0.0.0 when leveraging Vagrant port forwarding. Like so:
goapp serve -host=0.0.0.0
See the answers here for more info on ensuring the guest web server is not bound to 127.0.0.1 which is loopback. Web servers that bind to 127.0.0.1 (like App Engine Go dev web server does) by default should be overridden to use 0.0.0.0.

Tomcat 6 restrict access to web applications by URL

I have Apache Tomcat 6.0.35(Wndows 2008) with a bunch of application installed.
I have deleted webapps\ROOT*, renamed my application to ROOT.war, deployed and now I have my application as a root(the following URLs are used in the applications - http:/exampleapp.com/, http:/exampleapp.com/SomePostUri). Port 8080 changed to 80.
How I can forbid access(via HTTP) to the following applications:
1) Tomcat's Manager application (http:/exampleapp.com/manager/html) - allow access only from localhost.
2) All others installed web applications (e.g. http:/exampleapp.com/docs) - allow access only from localhost.
?
I installed Apache HTTP and joined it with Tomcat via mod_jk.
Solved.

Resources