Hey everyone! I’m having an issue with my subdomain.
What I have right now is two sites-available/enabled with what seems like the right server block info. I have 2 separate unicorn service files in init.d and 2 project folders /main-host and /subdomain. Each folder has their respective unicorn files and nginx files/server blocks.
If i kill service unicorn_example both the main site and the subdomain go down, but unicorn_subdomain doesnt actually affect anything.
I’ll post everything I have.
nginx/sites-available/example.com
upstream subdomain {
server unix:/home/rails/subdomain/shared/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
root /home/rails/subdomain/public;
server_name www.subdomain.example.org subdomain.example.org;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://subdomain;
}
}
nginx/sites-available/example
upstream app_server {
server unix:/home/rails/example/shared/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
root /home/rails/example/public;
server_name www.example.org example.org;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
server {
listen 443;
root /home/rails/example/public;
server_name www.example.org example.org;
index index.htm index.html;
ssl on;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
the important part of unicorn_example
USAGE="Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
# app settings
USER="user"
APP_NAME="example"
APP_ROOT="/home/$USER/$APP_NAME"
ENV="production"
# environment settings
CMD="cd $APP_ROOT && bundle exec unicorn -c config/unicorn.rb -E $ENV -D"
PID="$APP_ROOT/shared/pids/unicorn.pid"
OLD_PID="$PID.oldbin"
important part of subdomain
USAGE="Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
# app settings
USER="user"
APP_NAME="subdomain"
APP_ROOT="/home/$USER/$APP_NAME"
ENV="production"
# environment settings
CMD="cd $APP_ROOT && bundle exec unicorn -c config/unicorn.rb -E $ENV -D"
PID="$APP_ROOT/shared/pids/unicorn.pid"
OLD_PID="$PID.oldbin"
there aren’t any errors that I can find and I’ve checked everything I can think of. I think the issue lies with Nginx? With the subdomain dns setup, I created an A tag to point to the same IP and letting nginx take it from there. If you have any questions or need any more resources, let me know! Thanks for your 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, @hello194962ece2671bd808e65
Could you please check if the subdomain’s DNS is properly resolving? You can either ping it from the console or use any website like https://www.whatsmydns.net/ to check the DNS propagation.
Keep in mind that any DNS change might take up to 48 hours in order to fully update due to DNS cache from all the ISPs. Usually it happens a lot faster, but it still takes time to propagate and start to resolve.
Hope this helps.
Regards, Alex
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.