By amita mohite
I want to configure nginx for domain as well as sub domain on ubuntu as follows
mysite.in pointing to website demo.mysite.in pointing to demo project uat.mysite.in pointing to test project
My nginx conf looks like:
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;
server_name mysite.in;
location / {
root /home/amita/Website/website-v1;
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
}
server { listen 8087; listen [::]:8087 default_server ipv6only=on;
server_name demo.mysite.in;
location / {
root /home/amita/Project/frontend/demo/project/dist;
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
}
server { listen 8088; listen [::]:8088 default_server ipv6only=on;
server_name test.mysite.in;
location / {
root /home/amita/Project/frontend/test/project/dist;
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
}
mysite.in , demo.mysite.in, test.mysite.in all shows up webiste.
I am unable to rectify mistake. Please help !!
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!
Hello,
I have a subdomain setup but I’d do it all in DNS.
For domain.com I would insert an A DNS record with server IP. For the subdomains, I would create A records to the AWS server IP.
For an example of a nginx config file, this is how I’d do it. You should create a file like this on each server a domain or subdomain is pointing to. For example if domain.com is pointing to server1 and test.domain.com is pointing to server2, a nginx config file will need to exist on server1 and server2.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name domain.com www.domain.com;
root /path/to/web/files;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
}
It’s really more of a PHP configuration that I use on my WordPress setup, but it should point you in the right direction.
Thanks.
Hello,
I set my subdomains up in different files. One domain per file to keep things simple. All you really need to do is change the server name as you said. Then you should enable your new Nginx site configs and restart Nginx. This article should help you get up and running.
Hope it helps.
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.