Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have just set up a server on ec2, ubuntu with nginx and an ssl certificate through namecheap (who also provide my domain).
When I hit https://example.com the certificate comes up.
How can I make it so that if a user were to hit www.example.com or http://example.com that they use the https:// connection?
I think the following should work:
server {
server_name example.com;
listen 443 ssl default_server;
# your https-specific config
}
server {
server_name example.com;
listen 80;
location / {
return 301 https://example.com$request_uri;
}
}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm trying to set up a default server in nginx with SSL, path to SSL certificate should contain sitename, something like that
server {
listen 80 default_server;
listen 443 ssl default_server;
server_name _;
ssl_certificate ssl/$host_name/fullchain.pem;
ssl_certificate_key ssl/$host_name/privkey.pem;
and it doesn't work - in error log
cannot load certificate "/etc/nginx/ssl//fullchain.pem"
If I print this variable in headers with add_header XX "$http_host";
it shows the proper sitename. Is there any way to use sitename in certificate path? There are a lot of sites on my server with typical config so it's better for me to have just one config. Nginx version 1.18 and if I manually define some variable and put it in ssl_certificate parameter everything is working fine
You need to use $ssl_server_name instead of $host_name or $host - see an example in the docs. You see, the certificate is required before the client sends its HTTP request, so at that time $host_name and $host are not defined.
But as those docs say,
Note that using variables implies that a certificate will be loaded for each SSL handshake, and this may have a negative impact on performance.
So it's probably better to generate config files with fixed server names (and fixed certificate paths) for all your servers (using some kind of template).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I have a website that runs on a framework on a LAMP stack.
Now I want to extend this website by adding a bunch of new pages, but served from a different framework on a separate LAMP stack on another server that is prepared to handle more traffic.
I don't want this traffic to pass by the original website as it will be a burden to be processed by the framework. However, I can afford to have apache forwarding the traffic request to a specific folder forwarded to a separate server with a different IP address.
For example:
mydomain.com/ -> goes to server A,
mydomain.com/folder1/ -> goes to server B
How can I accomplish this with apache?
I can even afford setup a separated server to handle the separation of these request, so each server will only receive the requests it is intended to process.
Another option could be to set a subdomain like ww2.mydomain.com pointed to the IP of a separated server but will this affect my SEO ranking?
What are other options and what would be the best option for this case?
You are looking for ProxyPass directive.
Example location for mydomain.com virtualhost:
<VirtualHost ...>
ServerName mydomain.com
...
<Location /folder1/>
ProxyPass http://serverb/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>
</Virtualhost>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I need to redirect a particular url to my localhost in mac osx-yosemite. I'm able to do the port forwarding using the following.
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef -
But can't figure out how to make a particular URL to be redirected to my localhost. Thanks for the help
Edit your hosts file - should be at:
/private/etc/hosts
Add a new line
127.0.0.1 domain.com
This will make requests for domain.com be sent to your mac. You may need to close and reopen your browser to flush any local DNS cache it may hold.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm having trouble figuring out what's the proper way to setup a SSL virtual host + a non-SSL copy of it.
I have it like this now:
<VirtualHost myip:80>
plenty of directives here
</VirtualHost>
and
<VirtualHost myip:443>
same directives as above
</VirtualHost>
And it works fine but every time I edit the directives in one of the vhosts, I must do it in the other as well. Anything cleaner and more elegant?
To run a website on both HTTP and HTTPS URLs, your only option is to run 2 separate VirtualHosts with the same DocumentRoot.
If the directives context allows, you can keep some of the common settings in a .htaccess file in a folder that is parent to both DocumentRoots.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
How can I setup nginx as reverse proxy along with apache on CentOS 5.6
I have already install apache, but I dont know if I should proceed with installing nginx because I am afraid that may set nginx as the default server.
How do I proceed with the installation and set up configuration for nginx as a reverse proxy to serve static content?
yum install nginx
then setup nginx config to listen to port 80
and create virtual domain files
change the apache port to whatever listening port was set in nginx virtual domains file
restart both and voila!
use this link-> http://tumblr.intranation.com/post/766288369/using-nginx-reverse-proxy