0

I want to change Apache's port so I can use NGINx as a reverse proxy listening to port 80.

I changed the Listen 0.0.0.0:80 and Listen [::]:80 lines in the /etc/httpd/conf/httpd.conf file to Listen 0.0.0.0:8090 and Listen [::]:8090 and when I run sudo service httpd restart and then sudo service httpd status it says:

Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://localhost/whm-server-status

what else do I need to change in the httpd.conf file?

My NGINx conf file is

server{
        listen 80;
        server_name mywebpage.com;
        #access_log off;
        #error_log off;
        #large_client_header_buffers 4 16k;

#this one is for the node app 
        location / {
                proxy_set_header   X-Real-IP $remote_addr;
                proxy_set_header   Host      $http_host;
                proxy_set_header Connection "";
                proxy_pass http://127.0.0.1:8080;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }

#this one is for the apache one
        location /otherlocation {
                proxy_set_header   X-Real-IP $remote_addr;
                proxy_set_header   Host      $http_host;
                proxy_set_header Connection "";
                proxy_pass http://127.0.0.1:8090;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }

}

which works perfectly when I serve my node app but if I change Apache's port it won't work

EDIT: I also changed every <VirtualHost *:8090> and now it says

[Tue Feb 14 01:03:50 2017] [warn] VirtualHost 162.214.21.28:8090 overlaps with VirtualHost 162.214.21.28:8090, the first has precedence, perhaps you need a NameVirtualHost directive
[Tue Feb 14 01:03:50 2017] [warn] VirtualHost 162.214.21.28:8090 overlaps with VirtualHost 162.214.21.28:8090, the first has precedence, perhaps you need a NameVirtualHost directive
[Tue Feb 14 01:03:50 2017] [error] VirtualHost *:8090 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Feb 14 01:03:50 2017] [warn] VirtualHost 162.214.21.28:8090 overlaps with VirtualHost 162.214.21.28:8090, the first has precedence, perhaps you need a NameVirtualHost directive
[Tue Feb 14 01:03:50 2017] [warn] NameVirtualHost 162.214.21.28:80 has no VirtualHosts
[Tue Feb 14 01:03:50 2017] [warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts
LuisEgan
  • 952
  • 2
  • 13
  • 28
  • `sudo service httpd stop` works? – TRiNE Feb 14 '17 at 05:33
  • does this fixed your problem `ipcs -s | grep nobody | perl -e 'while () { @a=split(/s+/); print \`ipcrm sem $a[1]\`}'` – TRiNE Feb 14 '17 at 05:35
  • @TRiNE yes, I can stop the service, if I do it once it doesn't say anything, but if I run it twice it says 'httpd (no pid file) not running'. Can you explain what that does? – LuisEgan Feb 14 '17 at 05:39
  • @TRiNE it doesn't fix it. It just stays hanged saying `usage: ipcrm [ [-q msqid] [-m shmid] [-s semid] [-Q msgkey] [-M shmkey] [-S semkey] ... ] deprecated usage: ipcrm {shm | msg | sem} id ...` – LuisEgan Feb 14 '17 at 05:45
  • then, have you looked in httpd logs for startup errors? – TRiNE Feb 14 '17 at 05:47
  • @TRiNE where do I look them?? `/etc/httpd/logs/error_log` ? – LuisEgan Feb 14 '17 at 05:55
  • if so, I looked at them and it says a lot , but the warnings [warn] and error [error] are the ones that I posted in the edit – LuisEgan Feb 14 '17 at 05:58
  • Can you find `NameVirtualHost *:80` in `httpd.conf` ? Change it to `NameVirtualHost *:8090` – TRiNE Feb 14 '17 at 06:03
  • @TRiNE I can see it but it is between these comments `# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.` and just above are three includes, 2 are empties (pre_virtualhost_1.conf and pre_virtualhost_2.conf) and the other account_suspensions.conf just says `RewriteEngine On` – LuisEgan Feb 14 '17 at 06:13
  • Also, there are 3 NameVirtualHost: `NameVirtualHost my.Dedicated.Ip:80` , `NameVirtualHost 127.0.0.1:80` and `NameVirtualHost *` – LuisEgan Feb 14 '17 at 06:16
  • Try this first, change `NameVirtualHost 127.0.0.1:80` to `NameVirtualHost *:8090` – TRiNE Feb 14 '17 at 06:20
  • @TRiNE it gives me a new error `[error] VirtualHost *:8090 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results` – LuisEgan Feb 14 '17 at 06:25
  • Comment other `NameVirtualHost`s – TRiNE Feb 14 '17 at 06:28
  • @TRiNE ok, now it says `[warn] VirtualHost 162.214.21.28:8090 overlaps with VirtualHost 162.214.21.28:8090, the first has precedence, perhaps you need a NameVirtualHost directive` twice – LuisEgan Feb 14 '17 at 06:31
  • what shows for `sudo service httpd start` now? – TRiNE Feb 14 '17 at 06:41
  • @TRiNE that warning twice, and when I do `sudo service httpd status` it says it was unable to connect to remote host – LuisEgan Feb 14 '17 at 06:44
  • it seems beyond i cannot help you. will have to revert all things back to get work on port 80. then follow https://www.ostechnix.com/how-to-change-apache-ftp-and-ssh-default-port-to-a-custom-port-part-1/ – TRiNE Feb 14 '17 at 07:07
  • @TRiNE thanks for trying and for the link! – LuisEgan Feb 14 '17 at 07:10

0 Answers0