I have myapp.com for my main app, and api.myapp.com for api. Everything works fine and dandy at local development that's been serve with pow, however when I try to test on my nginx server api.myapp.com/v1/products/1 gives me a 404. (api.myapp.com redirects to myapp.com which is expected due to DNS setup)
I'm using, passenger+nginx, rails and grape-api, here are my setup:
routes.rb
constraints subdomain: 'api' do
mount API::Base, at: '/'
end
nginx conf
server {
listen 80;
listen [::]:80;
server_name myapp.com www.myapp.com api.myapp.com;
passenger_enabled on;
rails_env production;
root /path/to/myapp.com;
error_page 500 502 503 504 /50x.html;
location /50x.html {
root html;
}
}
I have CNAME *.myapp pointing to myapp.com.
I'd probably overlooked something that's fairly basic and fundamental, can someone point me to the right direction. Much appreciated.
Add 2 server blocks..
server {
listen 80 default_server;
server_name app.com;
...
}
server {
listen 80;
server_name subdomain.app.com;
...
}
Related
Here is my Nginx.conf file
Error message
Here is my nginx.conf file , also tried restart nginx,
But i can access container at this http://ipaddress:8888
server {
listen 80;
listen [::]:80;
server_name _;
#root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://18.215.189.243:8888/;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
I got this issue resolved,
the main problem was that I was using Nginx configuration in my host machine and uploading my code to the Nginx container.
I uninstalled nginx form my host machine and just using nginx container and it is working fine
I have a online shop that has creditcard payment with 3Dsecure.
When 3D secure navigates back to my site using url example.com/confirmPage/token I get a 405 not allowed from Nginx.
If I visit the page direct from my browser there is no problem also when I refresh the exact same page with the 405 error it loads perfectly fine.
It seems to be related to programmatic redirection to my site from 3DSecure.
Details:
Site is hosted in a AWS ECS Cluster which redirects to https so Nginx doesn't have to.
Site runs in a Docker container with Nginx
My Nginx config for the site looks like this:
events {
}
http {
include /etc/nginx/mime.types;
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name example.com *.example.com;
access_log /var/log/example/access/example.access.log;
error_log /var/log/example/error/example.error.log;
ssl_certificate /etc/ssl/certs/example.com.crt;
ssl_certificate_key /etc/ssl/private/example.com.pem;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html?/$request_uri;
}
}
}
This is copied over using a docker file.
Any help would be greatly appreciated.
My team mates managed to find the fix for this.
location / {
error_page 405 = 200 $uri;
try_files $uri $uri/ /index.html?/$request_uri;
}
405 (Not Allowed) on POST request - Esa Jokinen
I have installed NGINX and Passenger on Ubuntu 18.04 and am having issues getting any meaningful indication of what's wrong with my configuration.
/etc/nginx/nginx.conf
http {
# pretty much the default configuration except for this...
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-enabled/my_app (this is a symlink to sites-available)
server {
listen 80;
server_name my.app.ip.address;
root /path/to/public/folder;
passenger_enabled on;
passenger_app_root /path/to/app/root; # not public folder
passenger_ruby /home/appuser/.rvm/gems/ruby-2.0.0-p648/wrappers/ruby;
rails_env staging;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Results of systemctl status nginx
Results of passenger-status
Output of /var/log/nginx/error.log
When I try to access the IP address via a web browser, it refuses to connect and suggests I check the connection and firewall. Any thoughts on what the issue could be?
You need to remove passenger_app_root. That directive is for where passenger is, not the root of your app.
If you're using the standard RoR layout where public is a subfolder of the application root, you don't need to specify anything, but if they really are completely different than the directive you're looking for is passenger_root, which configures the root of your application.
I've just set up my first Digital Ocean VPS and managed to deploy my Rails app by following this guide: https://gorails.com/deploy/ubuntu/14.04
Unfortunatley I am still seeing the nginx splash page and hoep you guys can help me fix this?
In the nginx error log I am seeing this:
[ 2016-04-20 14:48:15.4541 31875/7f70762f57c0 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 31875
2016/04/21 14:58:58 [emerg] 1721#0: "listen" directive is not allowed here in /etc/nginx/sites-enabled/default.save:27
My nginx conf looks like:
server {
listen 80 default_server;
server_name dev.myapp.co.uk;
passenger_enabled on;
rails_env production;
root /home/deploy/myapp/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
I obviously have changed "myapp" to my correct domain and app name as appropriate.
Any ideas?
The issue seems like you are having two nginx configuration files inside /etc/nginx/sites-enabled/ and both of them have the same listen 80 default_server; line.
This is my first rails app i am deploying to a server other than heroku.I deployed my rails app to digitalocean successfuly. When i type the ipaddress in browser, home page shows up. But when i try to redirect to other controllers like xxx.xxx.xxx.xx/users/sign_in it show 404 Not Found. Also none of the images are showing up.
/etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name mydomain.com;
passenger_enabled on;
rails_env production;
root /home/deploy/myapp/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = / {
passenger_enabled on; <-added this line for home page to show up
}
location = /users/sign_in {
passenger_enabled on; <-added this line for sign_in view to show up
}
}
I dont know what i am missing. do I have to add passenger_enabled on; to each location?or is there a common configuration for all the uri's of the application?
I fixed it. Removed all location and added passenger_enabled on; outside.