Question
How to forward all requests to www subdomain including https requests?
I have a VPS with a Rails 4 application running on Ubuntu, NginX and Unicorn.
As I want all pages to be SSL encrypted, all requests to `http://` are forwarded to `https://` which is working fine.
This is an excerpt of my NginX configuration:
http { .... server { listen 80; server_name example.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443; server_name example.com; root /home/rails/public; index index.htm index.html; ssl on; ssl_certificate /etc/ssl/example.com.crt; ssl_certificate_key /etc/ssl/example.com.key; location / { try_files $uri/index.html $uri.html $uri @app; } location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; proxy_pass http://app_server; } } }How can I make it that all requests to `http://example.com` and `https://example.com` are forwarded to `https://www.example.com`? Thanks for any help.
Add a comment
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×