Code Monkey home page Code Monkey logo

nginx-config-hacks's People

Contributors

trwnh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

nginx-config-hacks's Issues

simpler "php in subdirectory"?

https://save.matbm.net/nsbwoasfiqbc.html?XJW5yw

I've had an issue where a PHP app was at the /virtual folder in my server. The fast_cgi was claiming "file not found".
fastcgi_param SCRIPT_FILENAME $document_root/virtual/$fastcgi_script_name; solved the issue. Since the fast_cgi will search for scripts at the /virtual folder now.

Currently there is phpsub.conf:

location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
}

and example subdirectory config:

# --------------------------------------
# octobercms running in subdirectory
# --------------------------------------
location /october {
alias /srv/http/trwnh.com/october;
try_files $uri $uri/ @october;
include snippets/phpsub.conf;
}
location @october {
rewrite /october/(.*)$
/october/index.php?/$1
last;
}

maybe play around with this to see how modular it could be? just looking at it quickly it seems like the SCRIPT_FILENAME line can be moved out of phpsub.conf and the rewrite block could be eliminated entirely...

also with this config in particular, alias directive may not even be necessary since the folder name and the uri path are the same. perhaps it could be eliminated as well, or a better example used (where the uri is different from the physical path on the system).

$document_root$fastcgi_script_name VS $request_filename

https://blog.martinfjordvald.com/2013/04/nginx-config-history-fastcgi_params-versus-fastcgi-conf/

i can't seem to find any downsides to just using $request_filename 100% of the time over $document_root$fastcgi_script_name for SCRIPT_FILENAME. $request_filename just seems to be less likely to break -- it takes alias into account,

Also https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#use-request-filename-for-script-filename

And if you use $request_filename, you should set index using index directive, fastcgi_index will not work.

which seems to be the only pitfall, per se.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.