Web front end running behind nginx not able to query API - api

I have a web front-end code running behind nginx which queries an API running on the same host on port 8080 , but the console logs show a :
GET http://sysops1.env.tools.com:8080/getblacklist net::ERR_CONNECTION_TIMED_OUT
while the curl requests are working fine .
What am I missing here ?
Edit :
the frontend code is placed under /var/www/ipblock and also I have added this to my nginx config to allow proxying :
location /ipblock {
proxy_pass http://sysops1.env.tools.com:8080/getblacklist;
}
Anything that needs to be modified in the nginx config .

Related

400 Bad Request load balancer for Apache servers with NGINX

I am using NGINX as load balancer for Apache WebServers (WordPress). All servers are made with AWS EC2. My config for NGINX:
cat /etc/nginx/sites-available/default
upstream web_backend {
server 35.157.101.5;
server 35.156.213.23;
}
server {
listen 80;
location / {
proxy_pass http://web_backend;
}
}
But after NGINX restart i am access load balancer via public ip and getting an error:
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to
use an ErrorDocument to handle the request.
Apache/2.4.29 (Ubuntu) Server at
ip-172-31-35-36.eu-central-1.compute.internal Port 80
If i refresh page i am getting same error but with another ip in the end (second server’s private ip), so i understand that NGINX do the work and it is Apache problem.
I tried to add 80 port for my servers in nginx config, replace ips with dns and private ip, but it didn’t help. Access log on Apache doesn’t show anything useful, just 400 errors.
What could be the problem?
Don’t use ‘_’ for upstream name, it was the only reason for my problem.
Just check on which ports are the Apache WebServers Running. You have to add those to your upstreams.
E.g.:
upstream web_backend {
server 35.157.101.5:8080; //assuming that your apache webserver is running on this port on this host
server 35.156.213.23:3000;//And a different port on the other.. you still need to add them here if your ports are same
}

Using "without" in http.proxy directive in Caddyfile in caddy

I'm using the caddy as a reverse proxy and the config is the
proxy /app http://myapp:8080 {
transparent
insecure_skip_verify
without /app
}
http://myapp:8080 is an Web application.
Here the request https://caddy/myapp redirects the request correctly but getting an error in the Web application while loading.
But if make the call as https://caddy/myapp/ then it works correctly.
what is the reason behind this and how to over come this one ?
How do I strip only "app" in the configuration ?
for example :
without app
Tried this but it isn't working .
Any help is really appreciated , Thanks in advance.

How to use Apache to redirect requests for Node-Red?

I'm running in AWS a Ubuntu with a docker server (managed by Portainer) with this two running containers:
1 - NodeRed (Serving my APIs)
2 - Apache (Hosts the site that consumes the APIs from NodeRed above)
I've configured a domain to this server and setted apache to work with SSL. The apache is running ok with my site through HTTPS, but the problem is that the NodeRed (that runs in port 1080) is not configured to run in SSL. This causes a malfunction in my website since that my API endpoints are being running under HTTP and being blocked by the browser due security reasons.
The question is: is there a way to create some kind of "mapping" in apache that receives the request from HTTPS and redirect to the NodeRed in HTTP (the two are running in same server)?
My idea is to create a subdomain like https://api.mysite.com that sends the request for apache and then apache redirects it to my NodeRed. Is that possible?
There is no need to expose the API to the outside world if you don't want to. Since your apache is running correctly and both containers are running on the same host, just use proxy to forward API requests to the API container.
You can achive this by add two lines to your apache config i.e.
ProxyPass /api/ http://127.0.0.1:1080/
ProxyPassReverse /api/ http://127.0.0.1:1080/

reverse proxy apache to localhost server

I've got a web app running on localhost:3000. I also have an apache server. I would like to reverse proxy the apache server so that requests to /mywebapp get forwarded to the server running on localhost:3000.
I currently have the following config at the bottom of my httpd.conf file, but I'm getting a server error when I try to access it:
ProxyPass /mywebapp http://localhost:3000
ProxyPassReverse /mywebapp http://localhost:3000
Edit - further details:
I'm running a jetty server with java -jar myapp.jar. I'd like to forward requests to an apache server listening on :80 to the jetty server.
I've got mod_proxy_http.so and mod_proxy.so enabled.
I can tell the server is running on localhost - it responds to curl with the appropriate http response. So I'm pretty sure the issue is with my apache setup, but I can't think what the problem would be.
Apache conf file in conf.d for reference: http://pastebin.com/vhXwjbQe
And I've got this in my httpd.conf:
Include conf.d/*.conf
It's hard to give a generic answer because every situation is different so here are some debugging questions to ask yourself:
if the protocol and port correct on the internal service, http and 3000.
Is the service actually listening for connections from localhost? is it running in a docker container etc that would require it to be listening on a different interface? You can check for this by looking at the output from mywebapp's logs and see if the request are making it through the proxy.
Do the paths on the internal service include the prefix that is being passed to Apache or does apache need to strip these off. if for instance mywebapp expects the path "/foo/bar" and apache's reverse proxy is sending it with the context path included "/mywebapp/foo/bar" then it will not match any path in mywebapp.

Redirect does not work?

I have a problem in the Apache config. On my localhost
return $this->redirect('ex::dashboard');
executes perfectly.
But when I upload the code to the server. It terminates with a blank page.
What could be the reason? I tried to debug.. but with no success.
I have access of the server and checked most of the PHP parameters.
'./configure' '--disable-fileinfo' '--disable-pdo' '--enable-bcmath'
'--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf'
'--enable-libxml' '--enable-mbstring' '--enable-soap' '--enable-sockets'
'--enable-zip' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs'
'--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr'
'--with-gd' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr'
'--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64'
'--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/'
'--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr'
'--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-openssl=/usr'
'--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre'
'--with-pic' '--with-png-dir=/usr' '--with-xpm-dir=/usr'
'--with-zlib' '--with-zlib-dir=/usr'
There is one difference in
LocalHost
Server API Apache 2.4 Handler Apache Lounge
Dedicated server
Server API CGI/FastCGI
Will this make a difference?
The code:
https://github.com/nilamdoc/vc.co.uk/blob/master/app/controllers/SessionsController.php#L33
at L33 it should redirect to the dashboard page
I also tried
header('Location: https://' . $_SERVER['SERVER_NAME']."/ex/dashboard");
but it did not redirect
Given the following:
I also tried
header('Location: https://' . $_SERVER['SERVER_NAME']."/ex/dashboard");
but it did not redirect
...this is not a Lithium question.
Are you sure it's even Apache? This:
Server API CGI/FastCGI
...does not seem to indicate.