80 이외의 포트에서 수신하도록 Apache 구성
나는 centOS 서버를 사용합니다. 포트 8079에서 수신하도록 아파치를 구성하고 싶습니다 httpd.conf
. LISTEN 8079 지시문을 .
iptables에서 포트 8079를 열고 iptables를 다시 시작했습니다. 심지어 iptables 서비스를 중단했습니다.
"netstat -nal | grep 8079" shows "tcp 0 0 :::8079 :::* LISTEN"
내가 액세스를 시도하는 경우 http://localhost:8079
또는 http://myserver.com:8079
그 기계에서, 그 페이지에 액세스 할 수 있습니다. 그러나 다른 컴퓨터에서 나는 80 이외의 포트에서 사이트에 액세스 할 수 없습니다. 포트 80에서 작동합니다. 포트 8079에서는 그렇지 않습니다.
그 밖에 무엇을 구성해야합니까?
에서 /etc/apache2/ports.conf
와 같은 포트를 변경
Listen 8079
그런 다음 /etc/apache2/sites-enabled/000-default.conf로 이동하십시오.
그리고 첫 번째 줄을 다음과 같이 변경하십시오.
<VirtualHost *: 8079>
이제 다시 시작
sudo service apache2 restart
Apache는 이제 포트 8079에서 수신 대기하고 / var / www / html로 리디렉션합니다.
텍스트 편집기에서 httpd.conf 파일을 엽니 다. 이 줄을 찾으십시오.
Listen 80
그리고 그것을 바꾸십시오
Listen 8079
변경 후 저장하고 아파치를 다시 시작하십시오.
방화벽 문제였습니다. 거의 모든 포트에 대한 액세스를 차단하는 하드웨어 방화벽이있었습니다. (소프트웨어 방화벽 끄기 / SELinux bla bla는 효과가 없음)
그런 다음 열린 포트를 스캔하고 열린 포트를 사용했습니다.
동일한 문제가 발생하면 다음 명령을 실행하십시오.
sudo nmap -T Aggressive -A -v 127.0.0.1 -p 1-65000
시스템에서 열려있는 모든 포트를 검색합니다. 열려있는 모든 포트는 외부에서 액세스 할 수 있습니다.
참조 . : http://www.go2linux.org/which_service_or_program_is_listening_on_port
80이 아닌 아파치 Listen 포트가 필요한 경우 우분투 아래에 다음 파일을 추가해야합니다.
"/etc/apache2/ports.conf"
청취 포트 목록
Listen 80
Listen 81
Listen 82
가상 호스트 conf 파일로 이동 한 후 다음을 정의하십시오.
<VirtualHost *:80>
#...v host 1
</VirtualHost>
<VirtualHost *:81>
#...host 2
</VirtualHost>
<VirtualHost *:82>
#...host 3
</VirtualHost>
이것은 Centos에서 나를 위해 일하고 있습니다.
First: in file /etc/httpd/conf/httpd.conf
add
Listen 8079
after
Listen 80
This till your server to listen to the port 8079
Second: go to your virtual host for ex. /etc/httpd/conf.d/vhost.conf
and add this code below
<VirtualHost *:8079>
DocumentRoot /var/www/html/api_folder
ServerName example.com
ServerAlias www.example.com
ServerAdmin root@example.com
ErrorLog logs/www.example.com-error_log
CustomLog logs/www.example.com-access_log common
</VirtualHost>
This mean when you go to your www.example.com:8079
redirect to
/var/www/html/api_folder
But you need first to restart the service
sudo service httpd restart
If you are using Apache on Windows:
- Check the name of the Apache service with Win+R+
services.msc
+Enter (if it's not ApacheX.Y, it should have the name of the software you are using with apache, e.g.: "wampapache64"); - Start a command prompt as Administrator (using Win+R+
cmd
+Enter is not enough); - Change to Apache's directory, e.g.:
cd c:\wamp\bin\apache\apache2.4.9\bin
; - Check if the config file is OK with:
httpd.exe -n "YourServiceName" -t
(replace the service name by the one you found on step 1); - Make sure that the service is stopped:
httpd.exe -k stop -n "YourServiceName"
- Start it with:
httpd.exe -k start -n "YourServiceName"
If it starts alright, the problem is no longer there, but if you get:
AH00072: make_sock: could not bind to address IP:PORT_NUMBER
AH00451: no listening sockets available, shutting down
If the port number is not the one you wanted to use, then open the Apache config file (e.g.
C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
open with a code editor or wordpad, but not notepad - it does not read new lines properly) and replace the number on the line that starts withListen
with the number of the port you want, save it and repeat step 6. If it is the one you wanted to use, then continue:- Check the PID of the process that is using that port with Win+R+
resmon
+Enter, click on Network tab and then on Ports subtab; - Kill it with:
taskkill /pid NUMBER /f
(/f
forces it); - Recheck
resmon
to confirm that the port is free now and repeat step 6.
This ensures that Apache's service was started properly, the configuration on virtual hosts config file as sarul mentioned (e.g.: C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf
) is necessary if you are setting your files path in there and changing the port as well. If you change it again, remember to restart the service: httpd.exe -k restart -n "YourServiceName"
.
For FC22 server
cd /etc/httpd/conf edit httpd.conf [enter]
Change: Listen 80 to: Listen whatevernumber
Save the file
systemctl restart httpd.service [enter] if required, open whatevernumber in your router / firewall
참고URL : https://stackoverflow.com/questions/3940909/configure-apache-to-listen-on-port-other-than-80
'development' 카테고리의 다른 글
Ruby에서 DateTime의 시간 부분 설정 (0) | 2020.08.29 |
---|---|
ASP.NET MVC에서 비활성화 된 입력을 제출하려면 어떻게합니까? (0) | 2020.08.29 |
새로운 computeIfAbsent 함수를 어떻게 사용합니까? (0) | 2020.08.29 |
React Native에서 ScrollView의 현재 스크롤 위치 가져 오기 (0) | 2020.08.29 |
XML 렌더링 오류 Android 미리보기 N (0) | 2020.08.29 |