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

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.

Related

Jersey + Grizzly behind Apache reverse proxy - Resource not found

I am having a jersey based REST Application which is running on grizzly and configured it as follows behind an apache reverse proxy
e.g. www.example.com/base/json/helloworld/get should redirect to my REST service. (Multiple Resources). However, when I try to open the url in the browser I always get a Resource not found.
In my apache config:
ProxyPass /base/ http://localhost:8123/
ProxyPassReverse /base/ "http://localhost:8123/
My grizzly server configuration is really simple and works if I do a curl request: curl localhost:8123/base/json/helloworld/get => Response is correct.
However, if I acess the url in my browser, e.g.
example.com/base/json/helloworld I am getting the grizzly error:
Resource identified by path /json/helloworld/get', does not exist.
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(http://localhost:8123/base), resourceConfig, false);
Am I missing something? I already tried changing the url to the domain and so on, but I can't get my head around why it doesn't work.
I found my fault. In the grizzly server my url was configured with the path /base/, but the Proxy Pass did not include the /base/ path at the end of the url. Now it works fine.

Web front end running behind nginx not able to query 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 .

Drupal - Mixed content error when using ssl certificate

I had a drupal installation working fine. I tried to migrate that one on a Docker Container runing behind a nginx reverse proxy. Everything seems fine but i have some .js and .css files that can't load because in drupal they are linked with http. The error is:
Mixed Content: The page at https://proxy.xx.xx/ was loaded
over HTTPS, but requested an insecure stylesheet
http://proxy.xx.xx/sites/default/files/css/css_xE-rWrJf-
fncB6ztZfd2huxqgxu4WO-qwma6Xer30m4.css'. This request has been
blocked; the content must be served over HTTPS.
I have something like 7 of them and i can't find where those files are called in drupal or how to change the http to https.
Best regards.
Alright, so I got to work by adding the following to the Drupal settings.php:
$conf['reverse_proxy'] = TRUE;
$base_url = 'https://whatever-your-domain-is.com';
$conf['reverse_proxy_addresses'] = array('internal_nginx_proxy_ip');
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
This works for jwilder's nginx-proxy container(s) together with JrCs' letsencrypt companion container. The nginx container is handling the HTTPS/SSL (certificates) and talks HTTP with the Drupal-container internally. The Drupal container only needs to be run with the 3 ENV VARS VIRTUAL_HOST, LETSENCRYPT_HOST, LETSENCRYPT_EMAIL for everything to be set up and work its magic.
Only downside: The Drupal container's apache logs show the internal IP of the nginx proxy. But the nginx logs show the correct client IPs and Drupal apparently gets them right as well, so it's only a minor nuisance for me.
I guess the additions to the settings.php should also be applicable to custom/manual setups.
We found what was wrong. Drupal was communicating with the Nginx proxy without ssl. Some config and it was ok.

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.

Cannot load socket.io.js with apache proxy setup

I feel like this question might be a duplicate but from all similar threads I have checked still wasn't able to find a answer.
I have vhost setup to proxy /node/ request to NodeJS/Socket.IO server.
ProxyRequests On
ProxyPass /node http://192.168.2.151:1337/
ProxyPassReverse /node http://192.168.2.151:1337/
This setup successfully serves everything from Apache, expect requests: http://domain.com/node/
Everything works fine when it comes to NodeJS.
I just can't get this line:
<script src="/node/socket.io/socket.io.js"></script>
to load socket.io.js, it always spits out what NodeJS server has to say.
The setup:
index.html is served by Apache. http://domain.com/index.html
index.html is simple HTML with script tag for loading socket.io.js (like I wrote above).
When I request http://domain.com/index.html script src is loaded but the content is NodeJS servers response instead of socket.io.js.
I have 'npm install socket.io' in the directory where NodeJS server is running from.
I have tried to serve index.html with NodeJS as well, regardless - socket.io.js content is still NodeJS responce.
Did anyone had this problem? Or could link me to an answer? :)
Cheers!
Look at this question and all of the answers at serverfault: Configuring Apache2 to proxy WebSocket?.
The problem is that mod_proxy doesn't support WebSockets and just makes it an HTTP request. You could use a different port and avoid proxying, switch to Nginx, try haproxy or use various other Apache module alternatives. For instance, mod_proxy_wstunnel is basically mod_proxy with WebSockets support. See the serverfault link above for details on all of the solutions.