Pylons redirect me on domain instead of subdomain - pylons

When I go to http:// sub.domain.com where is my Pylons project, application should redirect me on http:// sub.domain.com/login?redirect=/, but it's redirecting me on http:// domain.com/login?redirect=/
All redirections are to http:// domain.com/[rest of url]/ instead of http:// sub.domain.com/[rest of url]/ but project is under http:// sub.domain.com.
No-redirect requests works fine.
I use Pylons 1.0, mod_wsgi and Apache with virtual hosts.

Ok, solved. Just set map.sub_domains = False

Related

Redirecting www url to non www url in rails

I am able to redirect the base url of my website from www to non www in nginx configuration but the problem is I am sending email in which the url is with the www.
www.xyz.com -> xyz.com
successfully redirects but when I try to run the url like
www.xyz.com/pqr
it did not get redirected.
I am using rails 5.0.7 and ruby 2.5.1
There must be some issues in your nginx redirection config, try:
server {
server_name www.example.com;
rewrite ^(.*) https://example.com$1 permanent;
}
key is in keeping the path part of the url in $1

How to make a Rails app on Google App Engine redirect to HTTPS

I have successfully deployed my Rails app to the Google App Engine (my domain is also hosted by Google), and now I would like to redirect anyone going to my http:// address to my https:// address.
I have found the documentation to do so for a Python app here using the handlers element in the app.yaml file, and have attempted to replicate it in my own.
My app.yaml file now contains this:
handlers:
- url: /.*
script: config/application.rb
secure: always
redirect_http_response_code: 301
However I can still visit http:// without being redirected, and I think that it's because of the script: config/application.rb option that I've passed. I have no idea which file I should use or what that file should contain in a Rails app. Deployment breaks if I do not pass the script option.
Let me know if you need any more info, and thanks in advance for your help!
Well you can enforce SSL through your app's config/environments/production.rb file, you just need to add one line:
Rails.application.configure do
# Other code...
config.force_ssl = true # add this line to force HTTPS on production
end
This will do 3 things for your application, actually:
TLS redirect
Secure cookies: Sets the secure flag on cookies
HTTP Strict Transport Security (HSTS)
Read more about your application's configuration at http://guides.rubyonrails.org/configuring.html

How to disable /cpanel and /webmail etc

What is the best and most secure way to disable /cpanel and /webmail from the end of my website's URL?
I would like to disable them so they can't be accessed that way.
Thanks!
Assuming you have not fully control on your servers I mean to the OS through SSH, according to my assumption the easiest way would be redirect those urls to your home page. What web server do you use ? Nginx, Apache etc. ? If this is apache then what is the version ?
You can find your web server config edit section in Cpanel I'm not sure where it is.
There may be those url configs specified. The clear way would be remove them. But if you couldn't find it add one of the config according to your web sever and version
Apache 2.2
RewriteEngine on
RewriteRule (.*)/cpanel(.*)$ / [R]
RewriteRule (.*)/webmail(.*)$ / [R]
Apache 2.2 Doc
Apache 2.4
AliasMatch "(.*)/cpanel(.*)$" "/"
AliasMatch "(.*)/webmail(.*)$" "/"
Apache 2.4 Doc
Nginx
rewrite (.*)/cpanel(.*)$ / ;
rewrite (.*)/webmail(.*)$ / ;
Nginx Doc

My rails app is auto redirecting to https from http in production mode

My Rails application is working fine on dev mode.
In production mode the localhost:3000 is also opening nicely(with http), but on clicking signup link,
it's auto redirecting to "https://localhost/signup".
In production.rb file, i have marked
config.force_ssl = false
still it's auto redirecting to https from http.
Few links are working fine, where as in others the url is appended with https and no content is visible.
There is no trace in log/terminal for this issue.
I am using Rails 4.
Do this to find out if you are enforcing HTTPS in your controller or routes.
$ git grep force_ssl app/controllers
$ git grep https config/routes.rb

force_ssl working for http://www.domain.com but not http://domain.com

http://www.domain.com forwards to https://www.domain.com
but http://domain.com doesn't forward to https://domain.com
I am using nginx and unicorn, is there a way to fix this issue just in rails? Or does it require a nginx/unicorn settings change?
You can use https://github.com/stjhimy/rack-www to redirect all requests over to the www domain.
config.middleware.use Rack::WWW, :www => true

Resources