LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-01-2020, 08:07 AM   #1
orrin5250
LQ Newbie
 
Registered: May 2020
Posts: 3

Rep: Reputation: Disabled
Config problems - NGINX reverse proxy to Apache server for multiple subdomains


I will admit right off the bat I seem to be in over my head. I am a simple hobbyist.

I am trying to set up a website with multiple subdomains:

example.com
blog.example.com
cloud.example.com

I have Debain 10 installed on a VPS (Kamatera) and using *just* apache, I can browse each url and view a unique html page.

I then tried to set up nginx as a reverse proxy and despite scouring the net for days and making at least 10 different attempts...no luck. I seem to be missing something fundamental.

I believe DNS settings are correct (like I said, with apache alone, it's working):
Type Name Value
A @ 1.2.3.4 (of course not really)
A blog 1.2.3.4
A cloud 1.2.3.4

I have this added to apache2.conf file:
Code:
NameVirtualHost 1.2.3.4:8080

<VirtualHost 1.2.3.4>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost 1.2.3.4>
ServerName blog.example.com
DocumentRoot /var/www/html/blog
</VirtualHost>

<VirtualHost 1.2.3.4>
ServerName cloud.exmaple.com
DocumentRoot /var/www/html/cloud
</VirtualHost>
I have set /etc/apache2/port.conf to:
Listen 127.0.0.1:8080

These are my nginx.conf entries:
Code:
       server {
                listen          80;
                server_name     example.com;
                location / {
                        root /var/www/html;
                        proxy_pass http://127.0.0.1:8080/;
                        proxy_redirect http://127.0.0.1:8080/ http://example.com/;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;

                }
        }

       server {
                listen          80;
                server_name     blog.example.com;
                location / {
                        root /var/www/html/blog;
                        proxy_pass http://127.0.0.1:8080/;
                        proxy_redirect http://127.0.0.1:8080/ http://blog.example.com/;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;

                }
        }

       server {
                listen          80;
                server_name     cloud.example.com;
                location / {
                        root /var/www/html/cloud;
                        proxy_pass http://127.0.0.1:8080/;
                        proxy_redirect http://127.0.0.1:8080/ http://cloud.example.com/;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;

                }
        }
The trouble I am having is that browsing subdomains defaults to the home page html in /var/www/html. I have not successfully configured nginx so that I can browse the subdomains.

Ports:
Code:
orrin@orrin-cloud:~/old-nginx-attempt/nginx$ sudo netstat -anp | grep apache
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      26156/apache2       
orrin@orrin-cloud:~/old-nginx-attempt/nginx$ sudo netstat -anp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      26458/nginx: master 
unix  3      [ ]         STREAM     CONNECTED     226198   26458/nginx: master  
unix  3      [ ]         STREAM     CONNECTED     226197   26458/nginx: master
Any ideas? I am wondering if this is because there is nothing in my sites-available/enabled directories except default settings? Strangely enough with apache alone that somehow works.
 
Old 07-01-2020, 09:27 PM   #2
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 268

Rep: Reputation: 75
proxy_redirect is for different purposes. just use proxy_pass http://domain.example.org:8080/
And imo actually just use nginx.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Close docker ports after config of Nginx reverse proxy? nicedreams Linux - Containers 2 11-05-2019 09:54 PM
Nextcloud login loop on Nginx behind Nginx reverse proxy horizn Linux - Server 0 12-27-2018 02:44 PM
Nginx Reverse proxy on a internal apache reverse server ITiger Linux - Software 0 04-25-2014 07:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration