Welcome! Log In Create A New Profile

Advanced

Configuring nginx for both static pages and fcgi simultaneously

Denis Papathanasiou
July 31, 2016 06:58PM
I have the following configuration file defined in
/etc/nginx/conf.d/my-project.conf (this is on debian).

It does what I want, in that it serves static contet in the /css, /images,
/js folders along with index.html correctly.

And for dynamic requests (I'm running an fcgi-enabled server on port 9001)
to /contact, /login, and /singup it also works correctly.

I would just like to be able to declare that anything *except* index.html,
/css, /images, and /js, it should all go to the fcgi server.

I've experimented with various definitions of "location", but the only
one that seems to work is the one I have below, where all the possible
fcgi paths are defined explicitly.

Is there a better, simpler way of doing this?

server {
listen 80;
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name localhost;
root /var/www/my-project/html;

location / {
index index.html;
}

location /images/ {
root /var/www/my-project/html;
}
location /css/ {
root /var/www/my-project/html;
}
location /js/ {
root /var/www/my-project/html;
}

location ~ ^/(contact|login|signup)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9001;
}
}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Configuring nginx for both static pages and fcgi simultaneously

Denis Papathanasiou July 31, 2016 06:58PM

Re: Configuring nginx for both static pages and fcgi simultaneously

Maxim Dounin July 31, 2016 07:16PM

Re: Configuring nginx for both static pages and fcgi simultaneously

Richard Stanway July 31, 2016 07:40PM

Re: Configuring nginx for both static pages and fcgi simultaneously

Maxim Dounin July 31, 2016 07:52PM

Re: Configuring nginx for both static pages and fcgi simultaneously

B.R. August 03, 2016 01:10PM

Re: Configuring nginx for both static pages and fcgi simultaneously

Maxim Dounin August 03, 2016 08:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 112
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready