0

I've been pulling my hair out trying to get this to work. I'm trying to host the Cloud9 SDK (Node.js) app on port 8080 (or whatever port higher than 1024) and use Apache as a reverse proxy over HTTPS to that. It shouldn't be relevant, but I'm also using PM2 to ensure the server comes back up in case of a reboot or something like that.

Now, this works when reverse proxying over HTTP in Apache. It also works when reverse proxying over HTTPS in Nginx. The only reason I don't want to use Nginx is because the same server is also hosting Zoneminder, which is a headache to get working with Nginx (already tried). So I know there's no problem with the Node.js app itself.

I was originally following this article. After that, I did some extensive Googling. However, everything I've tried has not worked. At the root directory (/var/www/html/) I just have the default Apache landing page. This is where I'm taken instead of to my Node.js app.

This is what I have in my /etc/apache2/sites-available/000-default.conf file right now:

<VirtualHost *:80>
    #ServerAdmin webmaster@localhost
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html

    ServerName example.com
    ServerAlias www.example.com

    Redirect / https://example.com/
</VirtualHost>

<VirtualHost *:443>
    SSLEngine On
    #SSLProxyEngine On
    SSLCertificateFile    /etc/letsencrypt/live/example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

    ProxyPreserveHost On
    #ProxyRequests off
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>

And in case you're curious, this is what I had in my /etc/nginx/sites-available/default file:

server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    server_name example.com;

    ssl on;
    # Use certificate and key provided by Let's Encrypt:
    ssl_certificate      /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_session_timeout  5m;
    ssl_ecdh_curve       secp384r1;
    ssl_session_cache    shared:SSL:10m;
    ssl_session_tickets  off;
    ssl_stapling         on;
    ssl_stapling_verify  on;
    resolver             192.168.1.1 valid=300s;
    resolver_timeout     5s;
    add_header           Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
    add_header           X-Frame-Options DENY;
    add_header           X-Content-Type-Options nosniff;

    root /var/www/html;

    # Pass requests for / to localhost:8080:
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://localhost:8080/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
    }
}

Also, I'm not sure if this is relevant, but this is all on a Raspberry Pi 3b.

4
  • Can you please check the /var/log/apache2 directory? I suspect it is missing something really basic like enabling proxy_http
    – 473183469
    Jan 23, 2017 at 11:30
  • These are the 3 log files that exist: access.log, error.log, & other_vhosts_access.log. I just tried a2enmod proxy_http and it said the module is already enabled. Jan 23, 2017 at 13:03
  • It would be useful to know the exact error you read on the browser and the matching error in apache2 logs.
    – 473183469
    Jan 23, 2017 at 13:10
  • There is no error. I'm just taken to the default apache landing page residing at /var/www/html/index.html It's just not sending me to the node.js app. Jan 23, 2017 at 13:26

1 Answer 1

0

Ok, I figured out what the issue was. I realized that there were other sites enabled that needed to be removed. I had to a2dissite 000-default-le-ssl.conf and a2dissite default-le-ssl.conf not realizing that apache was looking at those configurations as well. I didn't think about it before because other changes I made to the 000-default.conf file were being reflected. Just not the ProxyPass.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.