Reputation: 273
My server listen 443 port and redirects the requests to another port in the server. Also my server listen 80 port and displays a static content the user when they browse http://www.xxxx.com
But I want also to display static content when user browse https://www.xxxx.com
How can I manage this ? My Nginx config file is ;
server {
listen 443 ssl;
server_name xxxx.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
expires off;
proxy_pass http://backend;
}
}
server {
listen 80;
listen [::]:80;
server_name xxxx.com;
root /var/www/xxxx.com/html;
index index.html;
location / {
try_files $uri $uri/=404;
}
}
I want to display my index.html file when user browse my website with https://www.xxxx.com and my proxy will continue to work at backend
Upvotes: 1
Views: 2464
Reputation: 49802
You can invoke a named location as the default action of your try_files
statement.
For example:
location / {
try_files $uri $uri/ @proxy;
}
location @proxy {
proxy_pass http://backend;
}
See this document for details.
Upvotes: 5