Azure App Service getting Error 404 when redirected via NGINX - azure

I created a VM, port 80 is open and installed NGINX on it.
I created 2 App Services which can be accessed via x1.azurewebsites.net and x2.azurewebsites.net
I configured the VM to act as an load balancer but when redirecting the traffic I get the following: https://i.gyazo.com/b94bed9c90d3b0f0c400c83f762f0544.png
I am not using my own domain. Does someone know what the issue could be?
I got the following configurations:
upstream backend {
server xx.azurewebsites.net;
server xxx.azurewebsites.net;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name_;
location / {
proxy_pass http://backend;
}
}

Azure App Service uses cookies for ARR (Application Request Routing). You have to make sure that your NGinx reverse proxy configuration pass the correct cookie / header to your web app.
The other possibility (to make sure the behavior comes from ARR) is to disable it: https://azure.microsoft.com/en-us/blog/disabling-arrs-instance-affinity-in-windows-azure-web-sites/

Related

How to handle Nginx reverse proxy 502 Error in specific case?

Here is my nginx default
server {
listen 80;
listen [::]:80;
server_name _;
location /login-with-args.html {
alias /opt/code-server/login-with-args.html;
}
}
And I am having login-with-args.html at this /opt/code-server/login-with-args.html location but the curl command in linux is giving me 200 but in my browser is it showing me 502 error.
this is what the url I am hitting from UI
https://url/login-with-args.html?password=1233&Id=12123&Code=sand-42&port=8127
Generally I could have advised you to enable error logging and check the corresponding log.
But as far as I see, there are mismatches in your question. Your configuration contains listen 80; which, in generally, means plain HTTP, except if you're add ssl parameter (anyway I'd not recommend you to enable SSL/TLS on port 80). But URL you try to request is:
https://url/login-with-args.html?password=1233&Id=12123&Code=sand-42&port=8127
which assumes using HTTPS on port 443 (by default, if not specified other).
At the same time there is no reverse proxy defined in your configuration. You just aliased static file.
Since you got 502 error, you nginx is either located behind some proxy (or CDN) or have another server section, containing listen with ssl parameter and reverse proxy definition somewhere in configuration.

Setting Up of Nginx reverse proxy

I have a node application running on an ec2 instance. Node is running on port 5000. I want to access the api from remote.
this is nginx configuration file.
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
client_max_body_size 20M;
listen 80;
listen [::]:80;
location / {
proxy_pass http://127.0.0.1:5000;
}
location /nginx_status {
# Turn on stats
stub_status on;
access_log off;
}
}
when I try to curl using curl localhost/nginx_status
it returns
Active connections: 1
server accepts handled requests
11 11 12
Reading: 0 Writing: 1 Waiting: 0
Also when I try to access the IP in browser, it shows
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
But if I try to access the ip_address/nginx_status it shows 404 Error for example if I took IP address 123.456.789.098 in browser it shows the above mentioned message and if I took 123.456.789.098/nginx_status it will return 404 error. Even if I try curl ip_address/nginx_status it is also returning 404 error.
My question is, How can I access node application running on port 5000 from outside world?
unfortunately I only see part of your config, is there another server that listens to 80?
You don't use "default_server" for listen either, and without "server_name" I find it difficult to distinguish between them. So maybe another config with the server + port 80 as default_server takes effect. Check in your /etc/nginx/ folder which servers {..} all exist.
The proxy_pass looks correct, if the nodjs server is really listed there, check again whether it is really http or https scheme. For the correct protocol transmission of the proxy_pass.
But you should then add a control for the "stub_status" so that it is information that you do not entrust to everyone, for me it is the case that only one application has access to it internally and under another list what is not released on the internet:
server {
listen 127.0.0.1:10081 default_server;
location /flyingfish_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
I'm curious what you find out! :)

Cloudflare - No further requests possible during download

My site allows users to download big .zip files. A problem I'm dealing with right now is that whenever the user is currently downloading such a file, all other requests to the site wait until the download is finished or cancelled, making the site practically unusable. In the Chrome network tab, the request shows as pending. Why could this be?
The server itself is implemented in Node.js using Express and is proxied through NGINX and then through Cloudflare. When I connect to the Express server or the NGINX proxy directly, this problem doesn't come up, only when it's routed through Cloudflare from what I have observed.
This is my NGINX config, if of any help:
server {
listen 80;
listen [::]:80;
server_name marbleland.vani.ga;
client_max_body_size 20m;
location / {
proxy_pass "http://localhost:20020/";
}
}
Am I missing something obvious?

Ubuntu 20 with NGINX add subdomain for existing IP

I have a small app written with NodeJS and it is hosted in Google Cloud. I reserved a IP and I can access the front of app with IP.
The problem is, I have an admin panel witch it is a different Node instance. This has his own port and I want to access it via url, like: http://admin.11.111.11.11
I've using NGINX with Ubuntu 20.4
Config for admin it looks like:
server {
listen 80;
listen [::]:80;
#server_name admin.11.111.11.111/ www.admin.11.111.11.111/;
location / {
#proxy_pass http://127.0.0.1:2222;
}
}
and for front:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name mydomain.com www.mydomain.com;
location / {
proxy_pass http://127.0.0.1:1111;
}
}
At this moment I can't transfer the domain. I must wait client to finish writing his content. The mydomain.com use an old CMS so we must wait to finish to transfer the content, so the new app it is accessible just through new IP.
Thank you for any hint!
This has his own port and I want to access it via url, like: http://admin.11.111.11.11
No, this isn't possible admin.11.111.11.11 is not a valid hostname. You can't mix hostnames and IP addresses as the host like that. This whole premise is flawed... this isn't an Nginx problem.

Cannot Connect subdomain of route 53 to ec2 node js app

But It's working fine with public IP as below
And I have created a subdomain with route 53 and then assigned A record with instance public IP
But when I ping the domain and IP it's getting request time out and all packets were lost. My application is node express app.So please it's a huge favor if anyone can solve this issue.
From your screenshot, I found that you're using Nginx as a Reverse proxy. So it might be because of your Nginx config
example your Nginx config may look like this,
server {
listen 80;
server_name 192.168.1.21;
...
}
you've to update it to:
server {
listen 80;
server_name subdomain.domain.com;
...
}

Resources