Redirect does not work? - apache

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.

Related

How to use SSL-certificates to call https://localhost with apache2 on Raspberry Pi

So I am currently working on a project where I use the Instagram API to get some user Data onto my Localhost webpage on the Raspberry. The API however needs secure redirect uri (https). But when the API wants do redirect to https://localhost/instagram it says
"404 Not Found The requested URL /instagram was not found on this server. Apache/2.4.25 (Raspbian) Server at localhost Port 443"
In the url-bar it says "Not secure", the https part is marked red and is crossed out. When I test my stuff on another computer which has Xampp and Apache running everything works fine and even if I type https://localhost it redirects straight to localhost.
I found out that I might need a SSL certificate in order to make use of https links even if I'm running on localhost. But I don't really know how I should do this on my raspberryPi. There are already some SSL modules enabled inside the Apache2 folder.

Create a subdomain for my domain

I have a server of OVH company and I'm having some problems setting a subdomain for it.
My server configuration is something like this:
Apache service working at port 80 with the website and works only with https (apache config makes a redirection for http request to https).
PostgreSQL service on default port 5432
Gitlab installation working over nginx at port 81.
I'm trying to set the external_url for gitlab to http://git.example.com:81 but when I try to access, i'm being redirected to a OVH default page.
I can access gitlab if I set the external url to something like http://example.com:81 or even if I set a relative path like http://example.com:81/gitlab but I can't make it work with the subdomain http://git.example.com:81
How do you think I can get it working? Maybe I have to change DNS zone or something related to the redirections in the OVH web manager panel??
Thanks in advance! This is a really great community!
(Posted on behalf of the OP).
I just assign in the panel of the web hosting this redirection: git.example.com => example.com and that does the trick.

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.

Tomcat serving URLs wrong with mod_proxy and apache

I've set up a host with apache to serve static pages and to use Tomcat to serve my web application (See this question). The static pages are server from
"http://myhost.com"
and the dynamic (tomcat) pages are server from
"http://myhost.com/myapp"
The mod_proxy makes sure the "http://myhost.com/myapp" are forwarded to tomcat server running on "http://myhost.com:8080".
The problem is that now you get the standard Tomcat introduction page on "http://myhost.com/myapp" but if you click on a local link (e.g. 'Status') on the left, it generates an URL
"http://myhost.com/manager/status" while it should generate: "http://myhost.com/myapp/manager/status"
(The same is true for webapps installed under tomcat)
What should be changed in my configuration (apache, tomcat?) to redirect my tomcat links to the right place?
Have you set the ProxyPassReverse setting in your httpd.conf. This will overwrite the HTTP Header an you'll get to the correct request on the side of tomcat.
Your URLs are mapped from:
http://myhost.com/myapp -> http://myhost.com:8080
This means that accessing the above URL will be mapped to the ROOT application in Tomcat. The ROOT application will generate pages that contain links from Tomcat's root context.
In other words, if you go to:
http://myhost.com:8080
you will get a page that contains links to
http://myhost.com:8080/manager/status
This link will work. However when that page is given back to a browser that requested it via Apache, the full URL then looks like: http://myhost.com/manager/status
I assume that you intend to deploy an application called 'myapp' to Tomcat? If that is the case the Tomcat URL for this app will be
http://myhost.com:8080/myapp
Which will also work be mapped correctly when accessed via Apache.
If you absolutely must access Tomcats root application in this way you'll have to rewrite the URLs it outputs in the pages it returns.
I've had the most success with mod_proxy_ajp. It requires mod_proxy, but works over ajp. Using it instead, your conf file looks similar
ProxyPass / ajp://localhost:8009/
See my similar question and also the answer to this question. The only fault in mod_proxy_ajp that I've found is that if I need to restart tomcat I have to force an apache restart too.

HTTP Authorization Rule in htaccess- convert to Nginx

I have recently moved my application from Apache to Nginx server. We have written
API's in Slim framework. So to enhance the basic security of API we have written token (static) based authentication(if-else loop) logic.
Below rule was added in .htaccess on the apache server which was working fine.
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
Now since we have moved to Nginx so above .htaccess rule will not work.
What changes do i need to make in Nginx config to get the above thing working.
It would be great if someone can explain the process step by step.
Thanks!
Try adding the following to your Nginx configuration.
fastcgi_pass_header Authorization;