How can I redirect all web requests to a specific subdomain on Nginx?In Nginx, how can I rewrite all http...

How could a female member of a species produce eggs unto death?

infinitive telling the purpose

Does the Bracer of Flying Daggers benefit from the Dueling Fighting style?

What is the difference between "shut" and "close"?

Is going from continuous data to categorical always wrong?

"One can do his homework in the library"

Have researches managed to "reverse time" and if so, what does that mean for physics?

This equation is outside the page, how to modify it

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

How could our ancestors have domesticated a solitary predator?

How do anti-virus programs start at Windows boot?

Latest web browser compatible with Windows 98

What wound would be of little consequence to a biped but terrible for a quadruped?

Touchscreen-controlled dentist office snowman collector game

Should QA ask requirements to developers?

How to deal with a cynical class?

How to make readers know that my work has used a hidden constraint?

Time travel short story where dinosaur doesn't taste like chicken

It's a yearly task, alright

Confusion with the nameplate of an induction motor

Who is our nearest neighbor

Best approach to update all entries in a list that is paginated?

Is it ok to include an epilogue dedicated to colleagues who passed away in the end of the manuscript?

Coworker uses her breast-pump everywhere in the office



How can I redirect all web requests to a specific subdomain on Nginx?


In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?Nginx has ssl module, but thinks it doesn'tBlank Page: wordpress on nginx+php-fpmHow to force or redirect to SSL in nginx?Nginx/Apache: set HSTS only if X-Forwarded-Proto is httpsNginX + WordPress + SSL + non-www + W3TC vhost config file questionsnginx reverse proxy hide login query also on 301 redirect or full qualified urlCodeIgniter nginx rewrite rules for i8ln URL'sConfigure NGINX : How to handle 500 Error on upstream itself, While Nginx handle other 5xx errorsNginx reverse proxy to many local servers + webserver duty













0















I have a website that I only want to serve requests at:



abc.mywebsite.com


I want any requests to:



www.mywebsite.com
mywebsite.com
<anything that is not abc>.mywebsite.com


to be directed to abc.mywebsite.com, because I have a certificate specifically for that. How can I write my conf file to accomplish this?



Here is my conf file as it stands:



server {
listen 80 default_server;
listen [::]:80 adefault_server;
server_name _;
return 301 https://$host$request_uri;
}

server {
listen 443 default ssl;
server_name abs.mywebsite.com;

ssl on;
ssl_certificate /etc/nginx/bundle.crt;
ssl_certificate_key /etc/nginx/abc.mywebsite.com.key;

ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;


root /home/mywebsite/public;

try_files $uri/index.html $uri @app;








share



























    0















    I have a website that I only want to serve requests at:



    abc.mywebsite.com


    I want any requests to:



    www.mywebsite.com
    mywebsite.com
    <anything that is not abc>.mywebsite.com


    to be directed to abc.mywebsite.com, because I have a certificate specifically for that. How can I write my conf file to accomplish this?



    Here is my conf file as it stands:



    server {
    listen 80 default_server;
    listen [::]:80 adefault_server;
    server_name _;
    return 301 https://$host$request_uri;
    }

    server {
    listen 443 default ssl;
    server_name abs.mywebsite.com;

    ssl on;
    ssl_certificate /etc/nginx/bundle.crt;
    ssl_certificate_key /etc/nginx/abc.mywebsite.com.key;

    ssl_session_timeout 5m;
    ssl_protocols SSLv2 SSLv3 TLSv1;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;


    root /home/mywebsite/public;

    try_files $uri/index.html $uri @app;








    share

























      0












      0








      0








      I have a website that I only want to serve requests at:



      abc.mywebsite.com


      I want any requests to:



      www.mywebsite.com
      mywebsite.com
      <anything that is not abc>.mywebsite.com


      to be directed to abc.mywebsite.com, because I have a certificate specifically for that. How can I write my conf file to accomplish this?



      Here is my conf file as it stands:



      server {
      listen 80 default_server;
      listen [::]:80 adefault_server;
      server_name _;
      return 301 https://$host$request_uri;
      }

      server {
      listen 443 default ssl;
      server_name abs.mywebsite.com;

      ssl on;
      ssl_certificate /etc/nginx/bundle.crt;
      ssl_certificate_key /etc/nginx/abc.mywebsite.com.key;

      ssl_session_timeout 5m;
      ssl_protocols SSLv2 SSLv3 TLSv1;
      ssl_ciphers HIGH:!aNULL:!MD5;
      ssl_prefer_server_ciphers on;


      root /home/mywebsite/public;

      try_files $uri/index.html $uri @app;








      share














      I have a website that I only want to serve requests at:



      abc.mywebsite.com


      I want any requests to:



      www.mywebsite.com
      mywebsite.com
      <anything that is not abc>.mywebsite.com


      to be directed to abc.mywebsite.com, because I have a certificate specifically for that. How can I write my conf file to accomplish this?



      Here is my conf file as it stands:



      server {
      listen 80 default_server;
      listen [::]:80 adefault_server;
      server_name _;
      return 301 https://$host$request_uri;
      }

      server {
      listen 443 default ssl;
      server_name abs.mywebsite.com;

      ssl on;
      ssl_certificate /etc/nginx/bundle.crt;
      ssl_certificate_key /etc/nginx/abc.mywebsite.com.key;

      ssl_session_timeout 5m;
      ssl_protocols SSLv2 SSLv3 TLSv1;
      ssl_ciphers HIGH:!aNULL:!MD5;
      ssl_prefer_server_ciphers on;


      root /home/mywebsite/public;

      try_files $uri/index.html $uri @app;






      nginx ssl redirect 301-redirect





      share












      share










      share



      share










      asked 7 mins ago









      AKWFAKWF

      2051312




      2051312






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f958160%2fhow-can-i-redirect-all-web-requests-to-a-specific-subdomain-on-nginx%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f958160%2fhow-can-i-redirect-all-web-requests-to-a-specific-subdomain-on-nginx%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          117736 Шеррод Примітки | Див. також | Посилання | Навігаційне...

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Маріан Котлеба Зміст Життєпис | Політичні погляди |...