Firefox/chrome shows apache request as blocked / stalled - apache

I'm using Apache 2.4.33 running on MacOs 10.13.6 as a local web development server
I ran some updates last week, mainly to update php from 7.1 to 7.2. This included a few tweaks to my httpd.conf namely to load a different php module.
I also recreated the server self-signed certificates as per instructions here: https://gist.github.com/jonathantneal/774e4b0b3d4d739cbc53
I've started getting errors on some web pages where some files included in the page are blank. these are both .js and .css files.
If I refresh the page, it is always the same 2 or 3 files.
As this is a dev environment, the files are sym linked from the web/assets directory through to the source directories.
I can't see any permissions problems. Other files in the same directory, with same ownership and permissions don't have the same error.
Looking at the network panel in FF, it lists the file, no error status, not even 200 - completely blank. I can't see the file in the Apache access_log either. Nothing in the error log.
If I look at the "Timings" sub-tab, it has a status of blocked.
I'm not running the MacOs firewall.
My htaccess is very basic:
Options +FollowSymLinks
IndexIgnore */*
# We need mod_rewrite for enablePrettyUrl
RewriteEngine on
RewriteBase /
# If the directory or file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
It's not CORS/cross domain ...
In FF the console gives a "Loading failed" error
in Chrome it gives "net::ERR_EMPTY_RESPONSE"
So, blocked by what?

it seems as though I had 2 versions of PHP installed. Apache line though I was using a homebrew installed version of 7.0 and the command line thought I was using the native 7.1
I guess somehow these were conflicting.
I ran brew uninstall php#7.0, brew cleanup & brew prune. Rebooted and everything worked OK.

Related

PHP Upgrade to 8 with Error Options -Indexes in .htaccess file

Have upgraded PHP 7.4 to to PHP 8.2.1 on mac osx, and for some reason, can not locate what is causing an issue with the .htaccess file having this code in it:
Options -Indexes -Multiviews
If I remove this code the site loads, but than shows all folders and files which is not desirable. Need site to load the index.php file that is being shown here, trying to hide this, but once this is in the .htaccess file, I'm getting the following error message:
Forbidden
You don't have permission to access this resource.
Is there something in PHP that needs to be set? I did change the php_module to point to PHP 8 in the httpd.conf file, so I don't understand what else might need to change to get my localhost loaded properly instead of showing files and folders?
BTW, this was working fine on PHP 7.4, but after updating, no longer works. Maybe I have to install other modules for 8.2.1 to work correctly?
If I switch back to using PHP 7.4 everything is loading fine on the site after restarting apache.
Need site to load the index.php file
You need to set the DirectoryIndex (mod_dir) - this defaults to index.html only (an Apache issue, not PHP). It is the DirectoryIndex that determines which file(s) Apache will try to serve when requesting a directory.
For example:
Options -Indexes -Multiviews
DirectoryIndex index.php
If a DirectoryIndex document (there can be more than 1) is not found... and mod_autoindex is disabled (ie. -Indexes) then you get a 403 Forbidden response. If mod_autoindex is enabled then you naturally see a directory listing. (If mod_autoindex is not installed at all then you get a 404 Not Found.)
mod_autoindex (ie. Indexes) is not enabled by default on Apache 2.4 (it is on Apache 2.2), however, it has likely been explicitly enabled elsewhere in the server config.

Can a NuxtJs "universal" application be served from an apache server or does it need to be served via node?

I am wondering if Apache can be set up to run a NuxtJs "Universal" app. From looking at the documentation it seems the "SPA" version of the app is built into a dist directory that I know I can serve from apache without any problems. It also looks like the "Static" build can be served from apache as well. but the Nuxt documentation for deploying a universal app says
• Upload the contents of your application to your server of choice.
• Run nuxt build to build your application.
• Run nuxt start to start your application and start accepting requests.
I do not believe that Apache has any way of nuxt build or nuxt start which are node commands.
In case if anyone's struggling with this:
You will have to have NPM (NodeJS) installed on your server. By the way you'll need SSH access to the server.
Then should upload the whole project to the server. Say you want to run the project in Development environment. You should run npm run dev and since the default port in development environment is 3000 , your .htaccess file should be as follows:
RewriteEngine On
DirectoryIndex disabled
RewriteRule ^$ http://127.0.0.1:3000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]

Apache 2.4 Internal mod_rewrite is not working

I have the following excerpt in my .htaccess file:
RewriteEngine On
# Whether RewriteBase is commented does not appear to have an impact on my problem
# RewriteBase /
RewriteRule ^admin/(.*) members/$1 [L]
The idea is that the pages in /admin load from the /members directory, since certain features are duplicated between them, so that I don't have to duplicate my code. (There are other directives in the file that are related to a CMS system, and those are working as expected.)
On the current Apache 2.2 server, everything works fine. My client's webhost wants to upgrade to a server with Apache 2.4, and on the test server the rewrite rule fails. Instead of loading the page, it just displays "File not found."
All other rules are executed as expected, it's just that one that fails. I have tried adding/removing / characters and removing [L] from the rule, it always fails. I tried adding [R] to send the redirect to the browser, but even that failed. But if I change the url to the same filename but in the members directory, then the file loads successfully.
Being able to change one directory name to another seems like a pretty basic function of mod_rewrite. What am I missing?

Mod rewrite enabled but not working in Apache

I currently use an iMac running Mavericks for development at work. I use the built in version of Apache and installed MySQL using homebrew when I first got the machine. Recently I had an issue where one of my virtual hosts was not working as expected and I ended up using Virtual Host X's restore command to wipe out my virtual hosts and start again.
I managed to get my vhosts working again but since then have noticed that mod_rewrite, although enabled, is not working. If I go to http://mywebsite.local/events I get an error
"Not Found -The requested URL /events was not found on this server." but if I go to http://mywebsite.local/index.php/events view the page fine.
I think restoring using Virtual Host X may have corrupted something in my Apache set up as the restore command does have this warning:
"Backup files contain all of your VirtualHostX data as well as copies of your web configuration files. Restoring a backup will replace those files and your current data (virtual hosts, domain details, etc) with the previously backed up data."
Here is a copy of my vhost settings for one of the sites I'm having issues with:
Options FollowSymLinks
AllowOverride None
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css|ttf|woff)$ /index.php
I first experienced this issue on Mountain Lion but have since upgraded to Mavericks hoping it would fix the issue but to no avail.
Any help would be great. If the issue can't easily be solved anyone with any advice about how to completely rid your machine of Apache and start again would also be helpful.
Thanks for your answer but unfortunately it didn't work out. However I am pleased to say the issue is now sorted. I pasted in your code and it stopped my virtual host from running altogether. I needed to paste my original code back in so copied and pasted it back in from this post in Stack Overflow and restarted Apache. I clicked on a few links and the rewrites are now working.
I'm guessing that there were some hidden characters which were causing the issue which were eradicated when I pasted the code back in.
I hope this helps someone as it was very annoying.
This should be used in Debian Apache2:
Options FollowSymLinks
AllowOverride None
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css|ttf|woff)$ /index.php [L]

Mercurial: "remote: ssl required" even when pushing to HTTPS repository

I have Apache and hgwebdir.cgi running fine via HTTPS (with a self-signed certificate), I can view the repositories via a browser and clone it locally. I don't know if it'd have any effect, but I'm rewriting the URLs to make them prettier:
$ cat .htaccess
Options +ExecCGI
RewriteEngine On
RewriteBase /public
RewriteRule ^$ hgwebdir.cgi [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) hgwebdir.cgi/$1 [QSA,L]
However, when I try to run hg push to send the changes back, I get this:
$ hg push
pushing to https://<repository>
searching for changes
http authorization required
realm: Mercurial
user: virtualwolf
password:
remote: ssl required
Apache is set to redirect all requests that are on HTTP to HTTPS. The remote server is running CentOS, with Apache 2.2.3 and Mercurial 1.3.1 (both installed via yum).
I've done a bunch of searching on this problem, the closest I've come to an answer is this but it's referring to NGINX not Apache.
Thanks!
You can resolve this problem by running hg server like this (no push ssl):
hg serve --config web.push_ssl=No --config "web.allow_push=*"
So it turns out the problem was the same as described here. It wasn't anything directly to do with Mercurial, but was oddness on Apache's end.
I had to copy the SSLEngine On and associated SSLProtocol, SSLCipherSuite, SSLCertificateFile, and SSLCertificateKeyFile directives from my separate "Enable SSL" Apache configuration file to my Mercurial virtual host file, even though everything else was working quite happily via HTTPS.
Add this lines to your central repository where you want to push
[web]
push_ssl=False
allow_push=*
Needless to say, this is rather unsafe, but if you’re on a nice protected LAN at work and there’s a good firewall and you trust everybody on your LAN, this is reasonably OK.