By Juxtapo
Hey,
I’m setting up a forum (NodeBB to be exact) on my Ubuntu 14.04 vps and have it up on example.com:4567. How would I go about routing this to forums.example.com using nginx? Here’s what I have for my DNS:
$ORIGIN example.com.
$TTL 1800
example.com. IN SOA ns1.digitalocean.com. hostmaster.example.com. 000000000 00000 0000 000000 0000
example.com. 1800 IN NS ns1.digitalocean.com.
example.com. 1800 IN NS ns2.digitalocean.com.
example.com. 1800 IN NS ns3.digitalocean.com.
example.com. 1800 IN A 1.1.1.1
www.example.com. 1800 IN CNAME example.com.
*.example.com. 1800 IN CNAME example.com.
forums.example.com. 1800 IN CNAME example.com.
www.forums.example.com. 1800 IN CNAME forums.example.com.
I have no clue what to use in my nginx config. I tried just doing a basic listen on port 4567 with a new sites-enabled config (as if it were a completely different domain) but forums.example.com would still just redirect to example.com.
Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This should do the trick:
server {
listen 80;
server_name sub.example.org
location / {
proxy_pass http://localhost:4567;
}
}
This defines a server listening at port 80 on the subdomain sub.example.org proxying requests to the server running at port 4567 on localhost. Be sure to restart nginx after you make the change:
service nginx restart
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.