<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=Nginx_Config</id>
	<title>Nginx Config - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=Nginx_Config"/>
	<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=Nginx_Config&amp;action=history"/>
	<updated>2026-06-08T21:27:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://w.electrodragon.com/w/index.php?title=Nginx_Config&amp;diff=26247&amp;oldid=prev</id>
		<title>Chao: Created page with &quot;  == Config == === Config sites file === backup site files in sites-available, activatived sites in sites-enabled, creat soft link from sites-available to sites-enabled. * def...&quot;</title>
		<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=Nginx_Config&amp;diff=26247&amp;oldid=prev"/>
		<updated>2020-05-01T10:47:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;  == Config == === Config sites file === backup site files in sites-available, activatived sites in sites-enabled, creat soft link from sites-available to sites-enabled. * def...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Config ==&lt;br /&gt;
=== Config sites file ===&lt;br /&gt;
backup site files in sites-available, activatived sites in sites-enabled, creat soft link from sites-available to sites-enabled.&lt;br /&gt;
* default config file:   nano /etc/nginx/sites-available/default&lt;br /&gt;
* create soft link to sites-enabled by ls -n /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com &lt;br /&gt;
&lt;br /&gt;
* link enable config file: /etc/nginx/sites-enabled/default&lt;br /&gt;
* delete etc/nginx/sites-avaialble/default&lt;br /&gt;
* edit /etc/nginx/sites-enabled/default&lt;br /&gt;
* set server_name www.example.com example.com;&lt;br /&gt;
&lt;br /&gt;
=== Futher Config ===&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Steps !! Header text !! Header text&lt;br /&gt;
|-&lt;br /&gt;
| Nginx config || /etc/nginx/nginx.conf || &lt;br /&gt;
|-&lt;br /&gt;
| Default site config || /var/www/html -&amp;gt; defined at /etc/nginx/sites-enabled/default || -&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* create file e.g. /etc/ningx/sites-enabled/iot.electrodragon.com.conf &lt;br /&gt;
* Optimize -&amp;gt; delete other conf file? [https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps FastCGI cache]?, gzip missing?&lt;br /&gt;
&lt;br /&gt;
=== Optimized ===&lt;br /&gt;
* sudo nano /etc/nginx/nginx.conf &lt;br /&gt;
* nginx -&amp;gt; [https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration enable gzip on, set staic file caching?, buffers, timetout]&lt;br /&gt;
&lt;br /&gt;
=== NGINX Config ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        listen 80;&lt;br /&gt;
        listen [::]:80;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/nginx/www;  # root of user file&lt;br /&gt;
	index index.html index.htm; # file name&lt;br /&gt;
&lt;br /&gt;
	server_name localhost; # e.g. www.electrodragon.com&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		try_files $uri $uri/ /index.html;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	location /doc/ {&lt;br /&gt;
		alias /usr/share/doc/;&lt;br /&gt;
		autoindex on;&lt;br /&gt;
		allow 127.0.0.1;&lt;br /&gt;
		deny all;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup for uwsgi ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        listen 80;&lt;br /&gt;
&lt;br /&gt;
        server_name www.portf.ltd portf.ltd;&lt;br /&gt;
&lt;br /&gt;
        # root /var/www/html;&lt;br /&gt;
        # index index.html;&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
                # try_files $uri $uri/ =404;&lt;br /&gt;
                include uwsgi_params; &lt;br /&gt;
                uwsgi_pass unix:/var/www/html/flask-test/sock.sock;&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Log ==&lt;br /&gt;
* /var/log/nginx&lt;br /&gt;
== Error Fix ==&lt;br /&gt;
upstream prematurely closed connection while reading response header from upstream&lt;br /&gt;
* Reference - https://stackoverflow.com/questions/27396248/uwsgi-nginx-flask-upstream-prematurely-closed&lt;br /&gt;
[[category: Nginx]]&lt;/div&gt;</summary>
		<author><name>Chao</name></author>
	</entry>
</feed>