http-server: How to disable charset for .wasm files? - macos

I am running a https server (Apache?) on my Mac. Done by this hints:
https://medium.com/#jonsamp/how-to-set-up-https-on-localhost-for-macos-b597bcf935ee
It serves my wasm-files with charset and I get: TypeError: WebAssembly: Response has unsupported MIME type 'application/wasm; charset=utf-8' expected 'application/wasm'
Changing .htaccess by adding
AddType 'application/wasm' .wasm
does not help. It feels like the server ignores .htaccess

Related

apache2 silent redirection not working as expected

I have a web server using apache2, and I want to silently redirect some pages.
So if an user try to access "http://website.com/test.php", the page at "http://website.com/fool.php" will be used instead. And i need to do that for several pages, not just test.php.
I though I could use the mod_rewrite module for this purpose, but I cant get it working.
I tried adding in apache2.conf, so i could have at least just a redirection for now (not silent):
RewriteEngine on
RewriteRule "^/test.php$" "/fool.php"
or
<Directory "/var/www">
RewriteEngine on
RewriteBase "/var/www"
RewriteRule "^/test.php$" "/fool.php"
</Directory>
This result in the test.php not being redirected at all (it still can be accessed), but also, it breaks my custom 404 and 403 pages with the error "ForbiddenYou don't have permission to access this resource.Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.".
Apache2 is not complaining about the syntax when i restart it.
Setting it in my sites-enabled config leads to the same result.
Note that the goal is not to prevent the direct access to test.php, and the request must result in a 200 success code.
There may be something i do not understand, because searching on the net, it looks like it's the way to achieve this.
You may try an alternative method: use the .htaccess file. (place the file in the root directory of your site)
For example:
RewriteEngine on
RewriteRule ^/test.php$ /fool.php [L]

Can PhpStorm debug a file that has been redirected to using Nginx's X-Accel-Redirect?

I'm using Nginx's X-Accel-Redirect to serve a file (redirected.php) that is outside of the webroot. The webroot is /usr/share/nginx/html and the file I am wanting to debug is being served from /usr/share/nginx/downloads
I begin Xdebug in the browser (debugging works at this stage). At some point the browser makes a request for website1.com/learning/downloads/url,
Nginx redirects the request to redirected.php using the below rule
# Enable X-Accel-Redirect
location /learning/downloads/ {
root /usr/share/nginx/downloads;
rewrite ^/(.*)$ /redirected.php last;
}
Unfortunately, I can't get redirected.php to pause on any breakpoints.
Is it not possible to debug when using X-Accel-Redirect with PhpStorm? or is it more likely to be a mapping issue? Suggestions on how to overcome this issue would be much appreciated.
It was a mapping issue. Part of the problem was due to redirected.php being in a folder outside the webroot.
To fix it, I went to File -> Settings -> Languages & Frameworks -> PHP -> Servers and configured it as in the picture below.
I also added xdebug_break(); to the code in redirected.php

404 not found for foundation source files

Running on nginx+laravel+foundation(simple css copy put into folders inside public directory) with a simple route and view and get 404 error for every source foundation file.
it looks like this for every file:
Remote Address:127.0.0.1:3000
Request URL:http://127.0.0.1:3000/css/normalize.css
Request Method:GET
Status Code:404 Not Found
tried different path notations(full, relative, via assets method or without it): same result.
can't find something informative on the issue within nginx logs.
and Uncaught ReferenceError: $ is not definedregister:65 (anonymous function) for these lines:
<script src="http://127.0.0.1:3000/js/vendor/jquery.js"></script>
<script src="http://127.0.0.1:3000/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
should be something simple, but just can't get it myself.
just fixed it: the problem was with my rewrites.
deleted this line from nginx.conf in the main server block:
rewrite ^.*$ /index.php last;
and got all the source files with no errors.

406 Not Acceptable on MacOSX Maverick

I am really new for Mac OSX, I had develop the web based application while communicate with another server.
Tried before on Linux, the scripts works well, but when I tried to implemented on Mac OSX server I got the error:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
Tried using .htaccess
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
and this:
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
I tried to testing this on Linux environtment, and works.
Anyone know how to fix this on Mac?
Thanks

mod_rewrite - redirect to a different url based on existence of x_wap_profile header

We have a desktop and a mobile version of our webapp.
The desktop url is more prominent and so we would like to redirect the user to the mobile version in case the request is for the desktop url from a mobile device.
In the apache config we have the mod_rewrite module
and my config at present looks like this
<IfModule mod_rewrite>
RewriteEngine On
RewriteCond %{x-wap-profile} ^https?://
RewriteRule ^/(.*) http://google.com [L,R]
</IfModule>
At this point this is the only rewrite rule that we have so I'm not sure if L is required because this is the first and last rule anyway.
I have just indicated redirection to google.com for testing purposes
I'm not sure if my condition check is right.I couldn't figure out how to check for existence of a header.Is that what is wrong?If yes,please let me know how to specify the RewriteCond
How I'm Testing?
I'm testing from a Firefox browser and using the Modify headers plugin to simulate the mobile request.I'm adding the x_wap_profile header.
However I don't see any redirect happening with this config.Can you please let me know where I'm going wrong?I would also appreciate if there is any logging that can be introduced here to verify if this rule is being trigerred.I don't see any errors though with the current modified config.
To check for an arbitrary header in mod_rewrite (i.e. a header not in this list), the syntax is:
RewriteCond %{HTTP:x-wap-profile}
This one seems to work:
RewriteEngine On
RewriteCond %{HTTP:x-wap-profile} ^.+
RewriteRule .* http://google.com [L,R]
piotrek#piotrek-Vostro-2520:~/vhosts/localhost$ curl http://localhost/
OKOK
piotrek#piotrek-Vostro-2520:~/vhosts/localhost$ curl -H 'x-wap-profile: abcd' http://localhost/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.6 (Ubuntu) Server at localhost Port 80</address>
</body></html>
Change it to make it work for https inside header.
Docs here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond in section Other things you should be aware of:.

Resources