Меню Рубрики

Nginx windows port 80

Завершение конфигурации NGiNX на 80-м порту

До тех пор, пока 80-й порт был занят Apache, NGiNX не мог запуститься, хотя синтаксис его конфигурационных файлов был без ошибок. (О том, как это всё выглядело и почему, подробно описано в → этой статье). Однако, после того, как Apache был перенесён с 80-го порта на 8080, ситуация поменялась. (О том, как поменять порт Apache c 80 на 8080 можно прочитать в → этой статье). Ниже рассмотрим завершение процесса запуска обоих WEB-серверов на разных портах.

Проверка синтаксиса и тест конфигурации WEB-сервера NGiNX

Проверим ещё раз синтаксис ВЕБ-сервера NGiNX:

Проверка синтаксиса и тест файла конфигурации никаких ошибок и предупреждений не выявляет. Можно попробовать ещё раз стартануть NGiNX.

Старт WEB-сервера NGiNX

Для старта ВЕБ-сервера NGiNX нужно выполнить команду:

Старт проходит тихо, без шума и пыли. Ура!

Проверка работы сервера на разных портах

Осталось проверить, всё ли у нас работает (и NGiNX на 80-м порту, и Apache на 8080-м порту, и то, что они друг другу не мешают).

Загружаем наш сайт по его доменному имени в браузере:

По умолчанию браузер настроен так, чтобы отправлять все http-запросы на 80-й порт сервера. Как видно на картинке выше, с 80-го порта ответил NGiNX. Тут всё Ok.

Проверим, что происходит на порту 8080. Для этого добавим к http-запросу номер порта в конце :8080

Как видно, тут тоже всё правильно. Ответ был получен от Apache с порта 8080.

Резюме

Таким образом удалось развести работу Apache и NGiNX на разные порты. Однако, нужно про это помнить в будущем при настройке виртуальных хостов так, чтобы вся статика отдавалась с 80-го порта NGiNX, а все динамически формируемые ответы пересылались на порт 8080, где их будет обрабатывать Apache.

Источник

Как настроить nginx на порт 80?

В данный момент у меня настройки виртуальных хостов на сервере такие:

nginx IP:8080
apache2 IP:8080

Вопрос, можно ли отправить nginx на 80 порт? И чем это обернется, так как в работе сейчас около 30-40 сайтов.

ServerName domain.ru
CustomLog /var/www/httpd-logs/domain.ru.access.log combined
DirectoryIndex /index.html
DocumentRoot /var/www/dns/data/www/domain.ru
ErrorLog /var/www/httpd-logs/domain.ru.error.log
ServerAdmin support@domain.ru
ServerAlias www.domain.ru
SuexecUserGroup dns dns

Options +ExecCGI -Includes
php_admin_value open_basedir «/var/www/user/data:.»
php_admin_flag engine on

nginx
location / <
proxy_pass http://IP:8080;
proxy_redirect IP:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
>

@RicoX эта команда netstat -nlp | grep 8080 ничего не выводит, сейчас у меня произошла ошибка, и мне пришлось вернуть все конфиги на старое, тоесть это:
nginx IP:81
apache2 IP:81

потому что IspManager создает домены на IP:81 не знаю почему

nginx УЖЕ у вас на 80 порту, отстаньте от него, apache смотрящий в мир вам вообще не нужен, пусть себе будет на 81 порту, но только локалхоста.
Делается так
nano /etc/apache2/ports.conf

NameVirtualHost 127.0.0.1:80
Listen 80

NameVirtualHost 127.0.0.1:81
Listen 127.0.0.1:81

Если сильно хочется именно сменить, меняйте скриптом в 2х местах во первых в конфиге апача, во вторых в конфиге nginx в настройках проксирования, но при перезапуске панель вам все равно вернет все назад, на сколько я помню ispmgr умеет ставить nginx только так, ну или спросить у их техподдержки.

/manimg/ <
alias /usr/local/ispmgr/skins/;
>
location ^

Источник

nginx not listening to port 80

I’ve just installed a Ubuntu 12.04 server and nginx 1.2.7, removed default from sites-enabled and added my own file into sites-available and symlink at sites-enabled . Then restarted nginx.

Problem: However going to the URL does not load the site. netstat -nlp | grep nginx and netstat -nlp | grep 80 both returns no results! lsof -i :80 also returns nothing. A dig from another server returns the correct ip address so it shouldn’t be a DNS problem. I was able to connect to apache which I have now stopped its service. nginx logs also show nothing.

How should I troubleshoot this problem?

/etc/nginx/site-available/mysite.com

10 Answers 10

I had this same problem, the solution was that I had not symlinked my siteconf file correctly. Try running vim /etc/nginx/sites-enabled/mysite.com —can you get to it? I was getting «Permission Denied.»

If your logs are silent on the issue, you may not be including the sites-enabled directory. One simple way to tell that the site is being loaded is to set the error/access log path within your server block to a unique path, reload nginx, and check if the files are created.

Ensure the following include directive exists within the http context in /etc/nginx/nginx.conf.

I ran into the same problem, I got a Failed to load resource: net::ERR_CONNECTION_REFUSED error when connecting over HTTP, but fine over HTTPS. Ran netstat -tulpn and saw nginx not binding to port 80 for IPv4. Done everything described here. Turned out to be something very stupid:

Make sure the sites-available file with the default_server is actually enabled.

Hope this saved some other poor idiot out there some time.

I’ve found it helpful to approach debugging nginx with the following steps:

1. Make sure nginx is running.

2. Check for processes already bound to the port in question.

3. Make sure nginx has been reloaded.

On Mac, brew services restart nginx is not sufficient to reload nginx.

4. Try creating simple responses manually to make sure your location path isn’t messed up. This is especially helpful when problems arise while using proxy_pass to forward requests to other running apps.

You are probably binding nginx to port 80 twice. Is that your full config file? Don’t you have another statement listening to port 80?

A semi-colon ; missing in /etc/nginx/nginx.conf for exemple on the line before include /etc/nginx/servers-enabled/*; can just bypass this intruction and nginx -t check will be successful anyway.

So just check that all instructions in /etc/nginx/nginx.conf are ended with a semi-colon ; .

Have you checked if your nginx binary really exists? please check if

outputs the binary path and check this path with your init script from /etc/init.d/nginx. e.g.

(In my init script «test -x $DAEMON || exit 0» is invoked and in any case this script returned nothing — my binary was completely missing)

In my case those network command’s outputs showed nginx was correctly binding to port 80, yet the ports weren’t externally accessible or visible with nmap .

While I suspected a firewall, it turns out that old iptables rules on the machine were redirecting traffic from those ports and conflicting with nginx. Use sudo iptables-save to view all currently applicable rules.

While we all think we don’t make silly mistakes, we do.

So, if you are looking into NGINX issues and all signs are showing it should work then you should take a step away from the files and look downstream.

System Firewall, Hardware Firewall, Nat router/firewall.

For myself this issue was my router, I run a home lab and so I can access services behind my router from afar I use NGINX to reverse proxy as my router only handles incoming based on IP and doesn’t do any handling of hostnames, I’m sure this is all fairly normal.

In any case my issue cropped up as I was securing my network a few days ago, removing some port forwarding that isnt needed any longer and I accidentally removed port 80.

Yes it was as simple as forwarding that port again to NGINX and all was fixed.

I will now walk away with my head hung in extreme shame though I leave this answer to show my gratitude to the people in this thread that lead me to find my own error.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Nginx rtmp module windows
  • Nginx rtmp hls windows
  • Nginx php mysql phpmyadmin windows
  • Nginx php fpm windows
  • Nginx php config windows