WebSocket handshake: Unexpected response code: 400 - websocket

Can't find out a solution. I'm not a lot into apache configs, but I currently need this to reroute to local server. I'm using solution for the reroute found somewhere in the internet. It worked. I have a connection, but I'm getting this error. WebSocket handshake: Unexpected response code: 400
Code:
<Location /tools/>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/tools/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule "^/tools/socket.io" "ws://localhost:8080/socket.io/" [P,L]
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>

Use Apache command:
a2enmod proxy_wstunnel
systemctl restart apache2

Related

My Laravel display main page but the rest not found in nginx server using aapanel

I have Laravel 6 running well on my localhost but when I deploy on domainsite.com, it only shows the main page but the rest of links shows 404 page not found. I am using CentOS 7, aaPanel running nginx server. PHP 7.4 MySQL.
I have this config so far.
URL Rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
fileinfo installed
I have removed in Disabled Functions(putenv and symlink) but still I get the error.
Anyone have tried this? Thank you!

How can I solve Server error! Error 500 when running app in xampp

I'm working on a website using codeigniter framework. I pasted all the package to phpdesktop because we were trying to convert it to desktop application which worked well. But when I move the folder to htdocs in xamp it failed to run, giving the below error:
Server error!
The server encountered an internal error and was unable to complete
your request. Either the server is overloaded or there was an error in
a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500 localhost
Apache/2.4.39 (Win64) OpenSSL/1.1.1b PHP/7.3.5
when I checked apache error log, I have this displayed:
[Fri May 10 18:36:37.353885 2019] [core:alert] [pid 14880:tid 1912]
[client ::1:58528] C:/xampp/htdocs/law/.htaccess: Invalid command
'//', perhaps misspelled or defined by a module not included in the
server configuration
htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sys_info/$1 [L]
How can I resolve it. It worked perfectly in phpdesktop in addition.
have you configured your index_page on config.php already? I you just leave it blank, here's a sample of .htaccess that's working for me:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this helps!

Http to Https AWS Elasticbeanstalk

I am using AWS Elasticbeanstalk for my Spring MVC web application. I want to redirect all the request to https. I tried following this How to force https on elastic beanstalk? but this didn't work for me. This code redirects to https but my app didn't work. It shows "This page isn’t working". Code for your reference
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<Proxy *>
Order Allow,Deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/ retry=0
ProxyPassReverse / http://localhost:8080/
ProxyPreserveHost on
ErrorLog /var/log/httpd/elasticbeanstalk-error_log
</VirtualHost>
Assuming you've already tested HTTPS working fine when your website is visited with HTTPS already. If not you can add this file .ebextensions/loadbalancer-terminatehttps.config with content as below:
option_settings:
aws:elb:listener:443:
ListenerProtocol: HTTPS
SSLCertificateId: arn:aws:acm:us-west-2:<your-account-id>:certificate/<certificate-arn-on-aws-acm>
InstancePort: 80
InstanceProtocol: HTTP
All what's left is to configure the instances Apache config to redirect the clients visiting your website with HTTP to HTTPS, add the code below to a new file .ebextensions/001_ssl_rewrite.config
Apache 2.4+
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
Apache 2.2.X
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
You can check which Apache is installed on your Elastic Beanstalk from here
For more, please read both of those answers: https://stackoverflow.com/a/38751749/1772245 and https://stackoverflow.com/a/40670047/1772245

Rewrite https Apache/Tomcat url

I have working apache connected with tomcat (mod_jk), I have set two virtualhosts:
myexample_8080.conf
myexample_4430.conf
I want to redirect all requests from http to https and on the home page of https://myexample.com redirect to tomcat url https://myexample.com/login
This is my first rule in myexample_8080.conf
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://myexample.com/$1 [R,L]
Everytime I ended up with redirect loop.
Solution
RedirectMatch 301 ^/*$ https://myexample.com/info

mod_rewrite redirects to .html in error

I've just setup an AMP server on OSX 10.9 and have a bizzare problem which is not present on my live hosting server or my old WAMP server.
I want to redirect any URL that doesn't directly map to a file on the server to index.php. I'm using the following .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# prevent loop
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*)$ /index.php?/$1 [L]
when I try http://example.com/example there is no problem, but when I introduce another slash, for example, http://example.com/example/
I get the a 404 error The requested URL /example.html/ was not found on this server.
Server version: Apache/2.2.26 (Unix)
Looks like your problem is related to enabling of MultiViews here. Turn it off by using this line on top of your .htaccess:
Options -MultiViews
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.

Resources