Nginx config file

This is a configuration file when using PHP, Python, Let's Encrypt with Nginx.

Confirmed on Ubuntu 18.04.

The server name is example.com.

/etc/nginx/sites-available/default


#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        index index.html index.htm index.php;

        server_name _;

        location / {
                try_files $uri $uri/ =404;
        }

#
        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        }

#
location ~ \.py$ {
        gzip off;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_index index.py;
        fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
        }
#
        listen  443 ssl;
        server_name     example.com;
        ssl_certificate         /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key     /etc/letsencrypt/live/example.com/privkey.pem;

}
#

Recommended Posts

Nginx config file
nginxparser: Try parsing nginx config file with Python
oslo.config config file search path
How to create a config file
File matching
File creation
Read file
File operations