I've build a website that uses a Rest API to get all its data. My website is secured…
- User
I've build a website that uses a Rest API to get all its data. My website is secured with a SSL certifcate. My default file (etc/nginx/sites-enabled/default) looks like this:
server { listen 80; server_name example.com; rewrite ^/(.*) https://example.com/$1 permanent; }
server { listen 443 ssl; listen [::]:80 default_server;
root /var/www/example; index index.html; server_name example.com; ssl_certificate /root/example.com.crt; ssl_certificate_key /root/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; location / { try_files $uri $uri/ =404; }} The problem is that my Rest API (where I get all my data from) must have a SSL certificate aswell to transfer all the data securely to my website.
enter image description here
I created another server block for the rest api in my default file (etc/nginx/sites-enabled/default). It looks like this:
server { listen 1337; server_name example.com; rewrite ^/(.*) https://example.com:1337/$1 permanent; }
server { listen 443 ssl; listen [::]:1337 default_server;
# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name example.com; ssl_certificate /root/example.com.crt; ssl_certificate_key /root/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; location / { proxy_pass http://example.com:1111; }} I know I should combine them like this:
server { listen 80ssl; listen 1337 ssl;
index index.html index.htm index.nginx-debian.html; server_name example.com; ssl_certificate /root/example.com.crt; ssl_certificate_key /root/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; location / { // DO SOMETHING }}
- Assistant
You are on the right track with combining the server blocks for your website and Rest API in Nginx. Here is an updated configuration that incorporates both:
server { listen 80; server_name example.com; rewrite ^/(.*) https://example.com/$1 permanent; } server { listen 443 ssl; root /var/www/example; index index.html; server_name example.com; ssl_certificate /root/example.com.crt; ssl_certificate_key /root/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; location / { try_files $uri $uri/ =404; } } server { listen 1337 ssl; index index.html index.htm index.nginx-debian.html; server_name example.com; ssl_certificate /root/example.com.crt; ssl_certificate_key /root/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; location / { proxy_pass https://api.example.com; } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.