<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Настройка домена nginx]]></title><description><![CDATA[<p dir="auto">Вот подробная инструкция по настройке домена через Nginx с двумя вариантами:</p>
<hr />
<h3>Общие шаги для обоих вариантов</h3>
<p dir="auto"><strong>Установите Nginx</strong></p>
<pre><code class="language-bash">sudo apt update
sudo apt install nginx
</code></pre>
<p dir="auto"><strong>Проверьте работу Nginx</strong><br />
Откройте браузер и перейдите по адресу <code>http://ваш_домен</code>. Должна отобразиться стандартная страница Nginx.</p>
<p dir="auto"><strong>Создайте папку для сайта</strong><br />
Если вы используете <strong>статический контент</strong>:</p>
<pre><code class="language-bash">sudo mkdir -p /var/www/ваш_домен/html
sudo chown -R $USER:$USER /var/www/ваш_домен/html
sudo chmod -R 755 /var/www
</code></pre>
<hr />
<h3>Вариант 1: Прямой доступ к файлам (статический сайт)</h3>
<p dir="auto"><strong>Создайте конфиг</strong></p>
<pre><code class="language-bash">sudo nano /etc/nginx/sites-available/ваш_домен.conf
</code></pre>
<p dir="auto">Вставьте конфиг:</p>
<pre><code class="language-nginx">server {
    listen 80;
    server_name ваш_домен www.ваш_домен;

    location / {
        root /var/www/ваш_домен/html;
        index index.html index.htm;
        try_files $uri $uri/ =404;
    }

    # Логи
    access_log /var/log/nginx/ваш_домен.access.log;
    error_log /var/log/nginx/ваш_домен.error.log;
}
</code></pre>
<p dir="auto"><strong>Активируйте конфиг</strong></p>
<pre><code class="language-bash">sudo ln -s /etc/nginx/sites-available/ваш_домен.conf /etc/nginx/sites-enabled/
sudo nginx -t  # Проверка синтаксиса
sudo systemctl reload nginx
</code></pre>
<p dir="auto"><strong>Добавьте тестовый файл</strong></p>
<pre><code class="language-bash">echo "Hello, World!" | sudo tee /var/www/ваш_домен/html/index.html
</code></pre>
<hr />
<h3>Вариант 2: Проксирование на Node.js через PM2</h3>
<p dir="auto"><strong>Запустите Node.js приложение через PM2</strong></p>
<pre><code class="language-bash">cd /путь/к/вашему_приложению
pm2 start app.js --name "ваше_приложение" -- --port 3000
</code></pre>
<p dir="auto"><strong>Создайте конфиг Nginx</strong></p>
<pre><code class="language-bash">sudo nano /etc/nginx/sites-available/ваш_домен.conf
</code></pre>
<p dir="auto">Вставьте конфиг:</p>
<pre><code class="language-nginx">server {
    listen 80;
    server_name ваш_домен www.ваш_домен;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Поддержка WebSocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    # Логи
    access_log /var/log/nginx/ваш_домен.access.log;
    error_log /var/log/nginx/ваш_домен.error.log;
}
</code></pre>
<p dir="auto"><strong>Активируйте конфиг</strong></p>
<pre><code class="language-bash">sudo ln -s /etc/nginx/sites-available/ваш_домен.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
</code></pre>
<hr />
<h4>Добавьте SSL-сертификат (Let’s Encrypt)</h4>
<p dir="auto"><strong>Установите Certbot</strong></p>
<pre><code class="language-bash">sudo apt install certbot python3-certbot-nginx
</code></pre>
<p dir="auto"><strong>Получите сертификат</strong></p>
<pre><code class="language-bash">sudo certbot --nginx -d ваш_домен -d www.ваш_домен
</code></pre>
<p dir="auto"><strong>Настройте автопродление</strong></p>
<pre><code class="language-bash">sudo crontab -e
</code></pre>
<p dir="auto">Добавьте:</p>
<pre><code class="language-cron">0 0,12 * * * root certbot renew --quiet &amp;&amp; systemctl reload nginx
</code></pre>
<hr />
<h4>Проверьте работу##</h4>
<ol>
<li>Откройте браузер и перейдите по адресу <code>https://ваш_домен</code>.</li>
<li>Убедитесь, что сайт работает через HTTPS.</li>
<li>Проверьте логи:</li>
</ol>
<pre><code class="language-bash">tail -f /var/log/nginx/ваш_домен.error.log
</code></pre>
<hr />
<h4>Частые ошибки и решения</h4>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Ошибка</th>
<th>Решение</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Port 80 failed to respond</code></td>
<td>Убедитесь, что Nginx запущен: <code>sudo systemctl status nginx</code></td>
</tr>
<tr>
<td><code>Could not open file /var/www/...</code></td>
<td>Проверьте права на папку: <code>ls -l /var/www</code></td>
</tr>
<tr>
<td><code>Connection refused</code></td>
<td>Убедитесь, что Node.js приложение запущено: <code>pm2 list</code></td>
</tr>
<tr>
<td><code>Certbot failed to authenticate</code></td>
<td>Проверьте DNS-записи вашего домена</td>
</tr>
</tbody>
</table>
<hr />
<h4>Дополнительно</h4>
<p dir="auto"><strong>Настройка автозапуска PM2</strong></p>
<pre><code class="language-bash">pm2 save
pm2 startup
</code></pre>
<p dir="auto"><strong>Резервное копирование</strong><br />
Создайте резервную копию конфига Nginx:</p>
<pre><code class="language-bash">sudo cp /etc/nginx/sites-available/ваш_домен.conf ~/ваш_домен.conf.bak
</code></pre>
<hr />
<p dir="auto">Теперь ваш домен настроен через Nginx с поддержкой HTTPS. Выберите подходящий вариант в зависимости от ваших задач:</p>
<ul>
<li><strong>Статический сайт</strong> → Вариант 1</li>
<li><strong>Node.js приложение</strong> → Вариант 2</li>
</ul>
]]></description><link>https://forum.exlends.ru/topic/127/nastrojka-domena-nginx</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 08:15:40 GMT</lastBuildDate><atom:link href="https://forum.exlends.ru/topic/127.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 May 2025 20:15:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Настройка домена nginx on Thu, 15 May 2025 14:58:13 GMT]]></title><description><![CDATA[<p dir="auto">@Jspi Да, соглы</p>
]]></description><link>https://forum.exlends.ru/post/236</link><guid isPermaLink="true">https://forum.exlends.ru/post/236</guid><dc:creator><![CDATA[kirilljsx]]></dc:creator><pubDate>Thu, 15 May 2025 14:58:13 GMT</pubDate></item><item><title><![CDATA[Reply to Настройка домена nginx on Thu, 15 May 2025 13:41:11 GMT]]></title><description><![CDATA[<p dir="auto">Пользователь @kirilljs написал в <a href="/post/234">Настройка домена nginx</a>:</p>
<blockquote>
<p dir="auto">0 0,12 * * * root certbot renew --quiet &amp;&amp; systemctl reload nginx</p>
</blockquote>
<p dir="auto">не обязательно перезапускать nginx</p>
]]></description><link>https://forum.exlends.ru/post/235</link><guid isPermaLink="true">https://forum.exlends.ru/post/235</guid><dc:creator><![CDATA[Aladdin]]></dc:creator><pubDate>Thu, 15 May 2025 13:41:11 GMT</pubDate></item></channel></rss>