Search Posts

HTTP not working, but HTTPS does in NGINX

Found an issue regarding with http url of site is not working, but sametime https does. Here the Nginx works as a Front End Proxy on port 80 for Apache.

tcp 0 0 IP:80* LISTEN 2023/nginx
tcp 0 0 IP:80* LISTEN 2023/nginx
tcp 0 0 IP:80* LISTEN 2023/nginx
tcp 0 0 IP:8081 IP:38574 ESTABLISHED 24791/httpd

Troubleshoot part
Section 1:

I tried first to switch to apache as main as follows, to verify if is clearly an issue only with nginx but not apache.

* Took a backup of apache conf with current date.
* vi /usr/local/apache/conf/httpd.conf and set parameter ‘Listen’ to ‘Listen’ under the line “# Defined in /var/cpanel/cpanel.config: apache_port”. Also replaced all ‘8081’ entries to ’80’, along with NameVirtualHost and in the virtual host.
* vi /var/cpanel/cpanel.config and set parameter ‘apache_port=’ to ‘apache_port=’. Then execute the following script to make the changes in effect.

/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings

* /etc/init.d/nginx stop
* /etc/init.d/httpd restart

Now apache would run as main webserver without any Front End proxy. Check the http url is loading fine or not. If it is working, the issue is regarding with nginx server.

Section 2:
* Check the nginx configuration for syntax errors.
root@host [~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
* Since I found the synax check is ok with nginx, turned by attention towards vhost entry for this domain in nginx.
* In the path, “/etc/nginx/vhosts” I could see vhost files for all domains but not the particular domain’s in question.
* I created one manually as follows:

root@host [~]# cat /etc/nginx/vhosts/
server {
error_log /var/log/nginx/vhost-error_log warn;
listen domainIP:80;
access_log /usr/local/apache/domlogs/ bytes_log;
access_log /usr/local/apache/domlogs/ combined;
root /home/cPanel_username/public_html;
location / {
location ~.*.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|
flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
expires 1d;
try_files $uri @backend;
error_page 405 = @backend;
add_header X-Cache “HIT from Backend”;
proxy_pass http://domainIP:8081;
location @backend {
proxy_pass http://domainIP:8081;
location ~ .*.(php|jsp|cgi|pl|py)?$ {
proxy_pass http://domainIP:8081;
location ~ /.ht {
deny all;

* Now I tried to switch nginx back as Front proxy. Reverted the changes made in “/var/cpanel/cpanel.config”, “/usr/local/apache/conf/httpd.conf”.
* Then make sure you executed the command “/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings” to make the changes in cpanel.config to be in effect. Then restart apache and start nginx.

You can see http url works as a charm 🙂

Please note that, next time when you face the same issue, you can directly go to section 2 for fast troubleshooting and closing the ticket.

2 comments on HTTP not working, but HTTPS does in NGINX

  1. Thanks for sharing this. Actually I managed to fix the issue even there is something slightly different affecting me.

    The domainA was using the main shared IP1. I have moved the user domainA to a dedicated IP2 and after that the HTTP stopped working. When checking the nginx vhost, the domainA file was actually there. I have just changed the old shared IP1 with the dedicated IP2 in listen and proxy and is working now.

    But the interesting thing is that I have another domainC with SSL using a different IP3 and the configuration is actually same with the shared IP1. So can’t understand why is working with one and not with the other one.

    The only difference between the two domains is that the domainC never used the shared IP1 when the cPanel user was created, but went straight with the dedicate IP3.

  2. I transferred the server from an old cPanel installation and the issue was the custom Apache configuration file from bluehosts VPS i transferred from.

    This is the s*it I found

    after removing it from

    and /scripts/rebuildhttpdconf

    I was blessed.
    I thought it was NGINX plugin Engintron but it wasn’t.
    And the root cause was because I migrated server configuration via transfer tool.
    Won’t do that ever again and all because of my laziness.

Leave a Reply

Your email address will not be published. Required fields are marked *