Hot answers tagged

8 votes
Accepted

Adding cache headers to Nginx configuation file breaks the /admin area

Craft rewrites the location of those files using a query string, which is what's causing nginx to lose track of them. Using the try_files directive should force nginx to find and serve them properly. ...
7 votes
Accepted

Asset URLs not HTTPS

Yii will check for the following server environment variables when determining if it’s an SSL request: HTTPS – should be set to “on”, “ON”, or “1”; or HTTP_X_FORWARDED_PROTO – should be set to “https”...
6 votes

Apache or Nginx for a Craft site

Putting aside Craft for a moment, it's not just Craft, you'll usually end up throwing more things on a web server as time goes by. If those scripts/apps are expecting an .htaccess file and you're ...
  • 6,502
6 votes

Apache or Nginx for a Craft site

There is no "this over that" for Craft specifically. Your own statement "it depends" plays a big role. I would read this pretty extensive post on DigitalOcean "Apache vs Nginx: Practical ...
  • 2,824
5 votes
Accepted

After upgrading to PHP 7 I started getting "storage folder isn't writable by PHP" errors

Try resetting the permissions of the storage folder: https://craftcms.com/docs/installing#step-2-set-the-permissions (It's possible that PHP was running with higher-than-default permissions in the ...
  • 3,400
5 votes

Unable to manage robots.txt in Craft

You can simply create a 'robots.txt' file in your templates folder and populate it using twig (templates do not need to end in .twig). Not sure what you're trying to control exactly, but something ...
5 votes

Non-default web port

For HTTP the default port is 80 and for HTTPS it's 443, obviously. If port is omitted in the site URL, then the default one is used. If you want to use a different port, you must specify a different ...
5 votes
Accepted

Nginx Vhost Config - Get page based on translated URI and without parameters in url

Ok, I got it working with: nginx vhost config: location /en/ { try_files $uri $uri/ @enrewrites; } location /nl/ { try_files $uri $uri/ @nlrewrites; } location / { try_files $uri $uri/ ...
  • 301
4 votes
Accepted

Why might the admin panel's font 404?

The request for the craft font needs to be rewritten, since the actual file is (usually) outside of the public web root. Usually, this will be handled by the location block in your nginx configuration ...
  • 7,248
4 votes
Accepted

Static page caching using Nginx FastCGI Cache with CraftCMS

The issue had something to do with PATH_INFO. Adding 'usePathInfo => true' in general.php fixed the issue. Here's the detailed explanation from Craft docs: https://craftcms.com/support/enable-path-...
  • 356
4 votes

Can I use an IP address instead of a FQDN?

First, I can positively confirm I have Craft running on two not hosted, local servers - one a Ubuntu 14.04 (well, Mint) installation, and one a Windows box using Uniserver. Not sure quite what you're ...
3 votes

Non-default web port

I'm not sure why you believe this is sub-optimal? You only have to set this once. I'm speculating here but since Craft makes no assumptions about your content, it stands to reason that it also makes ...
  • 6,502
3 votes
Accepted

Unable to manage robots.txt in Craft

It turns out this is an nginx problem. This post describes it: The troubling part of the nginx configuration looks like this location = /robots.txt { access_log off; log_not_found ...
3 votes

Admin assets not being served over https

So I added the following lines to my nginx file and it all worked location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { try_files $uri /index.php?$query_string; } ...
3 votes

Barebones LEMP + Craft CMS walkthrough

Here is one: https://medium.com/good-dog/deploying-craft-cms-to-amazon-ec2-running-the-lemp-stack-using-mina-e2ad955138fa#.54s4y29co Disclaimer: I work for the company that published this.
3 votes
Accepted

400 Bad Request on account or admin login

Add this to your nginx server block: server { ... large_client_header_buffers 4 16k; ... } and restart nginx. The default is 8k. If you have a lot of headers, beefing that value up should ...
  • 6,502
3 votes

Trailing slashes with Nginx and Craft

After some digging, there appear to be two ways that avoid hitting the admin and url query strings. The first, (and apparently better one, as 'if is evil' according to nginx) uses location handlers: ...
3 votes

Trailing slashes with Nginx and Craft

Nginx-Craft has an example setup that does this: https://github.com/nystudio107/nginx-craft/blob/master/sites-available/somedomain.com.conf#L60 # 301 Redirect URLs with trailing /'s as per https://...
  • 11.1k
2 votes

Asset URLs not HTTPS

An addition on this, probably for later versions of Craft than @brandonkelly's answer. You also need to be careful where Asset definitions are made in the CP - specifically, under Settings>Assets>...
  • 1,697
2 votes

multi environment nginx, how to check $_SERVER['SERVER_NAME']

$_SERVER['SERVER_NAME'] is a global server variable (not a craft variable) and should be available. I don't use nginx, so I can't comment on where the $_SERVER['SERVER_NAME'] comes from exactly — but ...
2 votes

Nginx: index.php URLs still being served alongside pretty URLs

I fixed it by adding rewrite ^/index.php/(.*) /$1 permanent; to my server block. This will redirect all urls containing index.php and something after it to the contents after index.php. E.g. /index....
  • 121
2 votes
Accepted

Upload images bigger than 1MB not working

Nginx's setting client_max_body_size was set to its default value of 1M because it was not specified after provisioning the DO server with Laravel Forge. Weird thing is just that the user doesn't get ...
  • 728
2 votes
Accepted

Redirects with Craft and nginx

To fix the "No Input File" in your Nginx config, you'll need something like this inside if your php location handler: try_files $uri $uri/ /index.php?$query_string; That will cause it to run the ...
  • 11.1k
2 votes
Accepted

Exclude path in NGINX config (for FastCGI Caching)

I've tried doing this with headers and cookies, but haven't had any luck yet. What I think is happening is that these things are set after the request is made. You are correct. fastcgi_cache is ...
  • 6,502
2 votes
Accepted

When saving an Entry, I receive a JSON response rather than returning to the Entry's edit page

IMO, the issue is with this line. SetEnv HTTP_ACCEPT text/html,application/xhtml+xml,application/xml,application/json;q=0.9,*/*;q=0.8 With ACCEPT headers set to a fixed value, it's impossible for ...
2 votes

shell script question on homestead

The best way to accomplish what you're trying to accomplish would be to utilize the after.sh shell script that Homestead provides. Check out Extending Homestead and Local Development with Vagrant / ...
  • 11.1k
1 vote

Load Balancing Craft CMS - Admin gets logged out instantly

If you can't enforce sticky sessions, then you'll need to provide a common place for all load balanced web server to save their PHP session files. By default PHP session files are file based and ...
  • 66.5k
1 vote

Static page caching using Nginx FastCGI Cache with CraftCMS

You might also need to add something like this for your actions pages: location ^~ /actions/users/setpassword { try_files $uri $uri/ @phpfpm_nocache; }
  • 33
1 vote
Accepted

Can I use an IP address instead of a FQDN?

Craft install (LAMP) LAMP Install Step 1: Install Apache and Allow in Firewall apt-get update apt-get install apache2 Set Global ServerName to Suppress Syntax Warnings apache2ctl configtest nano /...

Only top scored, non community-wiki answers of a minimum length are eligible